Answer the question
In order to leave comments, you need to log in
Implicit inheritance private?!?
I'll just leave the code:
# include < iostream >
class Base {
private:
int Var = 475 ;
public:
virtual int Get() const final {
return Var;
}
};
class Two : public Base {} ;
int main () {
Two two;
std :: cout << two . Get () ; /// 475, но как ?
std :: cin . get () ;
}
Answer the question
In order to leave comments, you need to log in
What's wrong with that? You have made a virtual method with an implementation. Then inherited the class without overriding the method. The method is public. The fact that he refers to private fields inside - does not matter. Private fields are contained in the successor, they are simply not available to him.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question