Answer the question
In order to leave comments, you need to log in
Who can write a program according to the mechanism of the compiler?
class A {
protected:
int i = 1;
public:
void func() { cout << " " << " "; }
};
class B :public A {
public:
B() { i++; }
void func1() { cout << " " << i << " "; }
};
int main() {
A a;
A *p;
p = &a;
B b;
p->func();
p = &b;
p->func();
((B*)p)->func1();
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question