How does C++ call the constructor of a parent class (even a parent's parent) in a child class?
In Java, we could have called the parent class constructor on the first line What should I do with C++
c++ inheritance constructor
Write as follows
class SuperClass
{
public:
SuperClass(int foo) {}
};
class SubClass : public SuperClass
{
public:
SubClass(int foo, int bar): SuperClass(foo) {}
};
It's on public right now, In c++, the private/protected/public keyword is the same as in Java.
© 2024 OneMinuteCode. All rights reserved.