[ create a new paste ] login | about

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

C++, pasted on Jan 19:
#include <iostream.h>
class A { 
protected:
int b;
public:
A():b(0) {}
int get_b() {return b;}

};

class B :public A {
int b;
public:
B():b(5)  { A::b = -1;}
int get_b() {return b;}
int get_A_b() {return A::b;}
};
int main()
{
B b;
A a ;//= &b;
std::cout << "it works" << '\t' << a.get_b() << '\t' << b.get_b() << '\n' << b.get_A_b();
return 0;
}


Output:
1
2
it works	0	5
-1


Create a new paste based on this one


Comments: