Files
Victor Eijkhout 675b5de981 updating
2023-06-04 12:45:32 -05:00

42 lines
850 B
C++

/****************************************************************
****
**** This file belongs with the course
**** Introduction to Scientific Programming in C++/Fortran2003
**** copyright 2017-2023 Victor Eijkhout eijkhout@tacc.utexas.edu
****
**** ptr1.cxx : shared pointers
****
****************************************************************/
#include <iostream>
using std::cout;
#include <memory>
using std::shared_ptr;
using std::make_shared;
class thing {
public:
thing() { cout << ".. calling constructor\n"; };
~thing() { cout << ".. calling destructor\n"; };
};
int main() {
//codesnippet shareptr0
cout << "Outside\n";
{
thing x;
cout << "create done\n";
}
cout << "back outside\n";
//codesnippet end
#if 0
// alternatively
auto thing_ptr1 = shared_ptr<thing>( new thing );
#endif
return 0;
}