Search⌘ K
AI Features

- Solution

Explore how to implement inheritance in C++ using private, protected, and public access specifiers. Understand how the using keyword helps call base class constructors, setting the foundation for mastering base class initializers in the following lesson.

We'll cover the following...

Solution

C++
class Base{
public:
Base(int){};
};
class DerivePublic: public Base{
using Base::Base;
};
class DeriveProtected: protected Base{
using Base::Base;
};
class DerivePrivate: private Base{
using Base::Base;
};
int main(){
Base(1);
DerivePublic(1);
DeriveProtected(1);
DerivePrivate(1);
}
...