CMP Carry/Overflow
Wednesday, October 27, 2010
Private Virtual Functions
#include
using namespace std;
class A
{
virtual void print1() { cout "1 Aprivate" endl; }
public:
virtual void print2() { cout "2 Apublic" endl; }
class B : public A
{
virtual void print2() { cout << "2 Bprivate" endl; }
public:
virtual void print1() {cout << "1 Bpublic" endl; }
int main(int argv, char* argc[])
{
A a;
B b;
a.print2();
b.print1();
A* ab = &b;
ab->print2();
return 0;
}
outputs...
2 Apublic
1 Bpublic
2 Bprivate
Subscribe to:
Posts (Atom)