q****2 发帖数: 7 | 1 I have two class A and B as fllowing
class A {
public:
int i;
public:
A() : i(1) { }
};
class B : public A {
public:
int i;
public:
B() : A(), i(2) { }
};
A has data i, B has a new data i, in fact B has two int numbers. I want to
know how to use the i defined in A with a B object.
Thanks a lot. |
t****t 发帖数: 6806 | 2 write A::i, then
【在 q****2 的大作中提到】 : I have two class A and B as fllowing : class A { : public: : int i; : public: : A() : i(1) { } : }; : class B : public A { : public: : int i;
|
q****2 发帖数: 7 | 3 Just figure out
b.A::i
b.B::i
Thanks
【在 t****t 的大作中提到】 : write A::i, then
|
d***y 发帖数: 65 | 4 why do u both name them "i"?
【在 q****2 的大作中提到】 : Just figure out : b.A::i : b.B::i : Thanks
|
d******n 发帖数: 42 | |
d******n 发帖数: 42 | 6 Guess you want to define a virtual function. |
l**a 发帖数: 423 | |