language: C++ 4.7.2 (gcc-4.7.2)
date: 726 days 14 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
 
using namespace std;
 
class First {
        public:
                int a;
                First() {};
                First(int a) {
                        this->a = a;
                }
 
                int getA() {
                        return a;
                }
 
                virtual int getB() {
                        cout << "getB() from super class..." << endl;
                        return 0;
                }
};
 
class Second : public First {
        public:
                int b;
                Second(int b) {
                        this->b = b;
                }
 
                int getB() {
                        cout << "getB() from child class..." << endl;
                        return b;
                }
 
};
 
int main() {
        First* t = new Second(2);
        cout << t->First::getB() << endl;
 
}