public
Last active

stack

  • Download Gist
stack.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#include <iostream>
 
using namespace std;
 
class CC
{
public:
int x;
CC() : x(5) { cout << "ctor" << endl; }
CC(const CC& c) { cout << "copy ctor" << endl; }
~CC() { cout << "dtor" << endl; }
};
 
class C
{
public:
CC * x;
};
 
 
void f(C * c)
{
CC cc;
c->x = &cc;
}
 
int main()
{
C c;
f(&c);
cout << c.x->x << endl;
return 0;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.