Skip to content

Instantly share code, notes, and snippets.

@maplebeats
Created March 26, 2014 15:24
Show Gist options
  • Save maplebeats/9785935 to your computer and use it in GitHub Desktop.
Save maplebeats/9785935 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
class Test
{
private:
int a;
public:
int *b = new int;
public:
Test(){
a = 0;
*b = 10;
};
~Test(){
this->a = 99999;
delete b;
this->print();
};
virtual int print(){
cout<<"hello world|"<<a<<"|"<<*b<<endl;
return 0;
};
};
int main()
{
Test t;
*(t.b)=9;
t.print();
Test * t2 = new Test();
t2->print();
delete t2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment