[ create a new paste ] login | about

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

C++, pasted on Jan 15:
struct A
{
virtual void Foo() { std::cout << "Foo A\n"; }
};


struct B : A
{
virtual void Foo() { std::cout << "Foo B\n"; }
};


struct C : A
{
virtual void Bar() { std::cout << "Bar C\n"; }
};

int main()
{
A * a = new A();
A * b = new B();
A * c = new C();
a->Foo();
b->Foo();
c->Foo();
c->Bar();
delete a;
delete b;
delete c;
return 0;
}


Output:
1
2
3
In function 'int main()':
Line 26: error: 'struct A' has no member named 'Bar'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: