N
Nasim
Suppose I have a code like following
////////////
class A {
int a;
public:
A() : a(1) {}
int get() const { return a; }
}
class B : public A {
int b;
public:
B() : b(2) {}
int get() const { return a+b; }
}
int main() {
B b;
cout << b.get(); //3
}
//////////////
Can I call get() function of the class A from the instantiated variable
b of class B? If not, how to achieve this without using pointers!
////////////
class A {
int a;
public:
A() : a(1) {}
int get() const { return a; }
}
class B : public A {
int b;
public:
B() : b(2) {}
int get() const { return a+b; }
}
int main() {
B b;
cout << b.get(); //3
}
//////////////
Can I call get() function of the class A from the instantiated variable
b of class B? If not, how to achieve this without using pointers!