Skip to content

Instantly share code, notes, and snippets.

@awnion
Created September 2, 2012 06:32
Show Gist options
  • Save awnion/3595360 to your computer and use it in GitHub Desktop.
Save awnion/3595360 to your computer and use it in GitHub Desktop.
class Foo
{
public:
Foo(int j) { i=new int[j]; }
~Foo() { delete i; }
private:
int* i;
};
class Bar: Foo
{
public:
Bar(int j) { i=new char[j]; }
~Bar() { delete i; }
private:
char* i;
};
void main()
{
Foo* f=new Foo(100);
Foo* b=new Bar(200);
*f=*b;
delete f;
delete b;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment