[ create a new paste ] login | about

Link: http://codepad.org/AKWhbBiV    [ raw code | output | fork ]

C++, pasted on Apr 21:
#include <iostream>

using namespace std;

class C {
public:
  ~C () { cout << "Destructor" << endl; }
};

C test1(C arg_obj) {
  return arg_obj;
}

C test2(void) {
  C l_obj;
  return l_obj;
}

int main(void)
{
  C c;
  cout << "--Start 1--" << endl;
  c = test1(c);
  cout << "--End 1--" << endl;
  cout << "--Start 2--" << endl;
  c = test2();
  cout << "--End 2--" << endl;
  
  return 0;
}


Output:
1
2
3
4
5
6
7
8
9
--Start 1--
Destructor
Destructor
--End 1--
--Start 2--
Destructor
Destructor
--End 2--
Destructor


Create a new paste based on this one


Comments: