mirror of
https://github.com/VictorEijkhout/TheArtOfHPC_vol3_cppf08programming.git
synced 2026-01-24 22:44:48 +09:00
45 lines
946 B
C++
45 lines
946 B
C++
/****************************************************************
|
|
****
|
|
**** This file belongs with the course
|
|
**** Introduction to Scientific Programming in C++/Fortran2003
|
|
**** copyright 2016-9 Victor Eijkhout eijkhout@tacc.utexas.edu
|
|
****
|
|
**** destructor.cxx : illustration of objects going out of scope
|
|
****
|
|
****************************************************************/
|
|
|
|
#include <iostream>
|
|
using std::cin;
|
|
using std::cout;
|
|
|
|
//examplesnippet destructor
|
|
class SomeObject {
|
|
public:
|
|
SomeObject() {
|
|
cout << "calling the constructor"
|
|
<< '\n';
|
|
};
|
|
~SomeObject() {
|
|
cout << "calling the destructor"
|
|
<< '\n';
|
|
};
|
|
};
|
|
//examplesnippet end
|
|
|
|
int main() {
|
|
|
|
//examplesnippet destructoruse
|
|
cout << "Before the nested scope"
|
|
<< '\n';
|
|
{
|
|
SomeObject obj;
|
|
cout << "Inside the nested scope"
|
|
<< '\n';
|
|
}
|
|
cout << "After the nested scope"
|
|
<< '\n';
|
|
//examplesnippet end
|
|
|
|
return 0;
|
|
}
|