Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class A {
- protected:
- int v;
- public:
- A () {v = 0; };
- void m1 () {
- v += 10; m2 ();
- };
- void m2 () {
- v += 20;
- };
- int getv () {
- return v;
- };
- };
- class B: public A {
- public:
- void m2 () {
- v += 30;
- };
- };
- int main (){
- B * Obj = new B ();
- Obj-> m1();
- Obj-> m2();
- cout << Obj-> getv () << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement