1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
struct Class1
{
void DoStuff(){} //this is public
protected:
void DoThing(){} //this is protected
private:
void DoAnother(){} //this is private
};
struct Class2 : Class1 //public inheritance
{};
class Class3 : Class1 //private inheritance
{};
struct Class4 : protected Class1 //protected inheritence
{};
|
Class1::DoStuff is public
Class1::DoThing is protected
Class1::DoAnother is private to Class1
Class2::DoStuff is public
Class2::DoThing is protected
Class2::DoAnother is private to Class1
Class3::DoStuff is private to Class3
Class3::DoThing is private to Class3
Class3::DoAnother is private to Class1
Class4::DoStuff is protected
Class4::DoThing is protected
Class4::DoAnother is private to Class1
Note that, just as Class4 specified protected, you can also specify public and private. You do not have to specifically use class or struct, they just have those defaults.