using namespace std;
Class A {
Public:
int a;
Int aaa (int aa);
};
{int A: : aaa (int aa)
A=aa;
Cout & lt; return a;
}
Class B: public A {
Public:
int b;
Void BBB (int bb) {
B=bb + a;
Cout & lt;
};
Int main () {
A a;
A.a aa (10);
B B;
B.b bb (20);
}
The output is 10 and a - 858993460
How can my desired output is 10 and 30, that is, the value of the object of A class I create in brackets, how can I make B class to create an object reference?
CodePudding user response:
Seems you need A class B as members of A class object, rather than inherited class A,CodePudding user response:
The b high for a metaclass can access a class member