#include using namespace std; /* class the_thing { public: int val; ~the_thing(){ cout << "Destructor Was Called\n"; } }; */ class the_thing { public: int *val; the_thing() { val = new int; } ~the_thing() { cout << "Destructor Was Called" << endl; delete val; } }; void pass_by_value(the_thing p){ cout << *p.val << endl; *p.val = 26; cout << *p.val << endl; } void pass_by_reference(the_thing &p){ cout << *p.val << endl; *p.val = 26; cout << *p.val << endl; } void pass_an_address(the_thing *p){ cout << *p->val << endl; *p->val = 26; cout << *p->val << endl; } int main(){ the_thing x; *x.val = 3; pass_by_value(x); cout << "Ending val " << *x.val << endl; return 0; }