user658266
user658266

Reputation: 2435

c++ derived class question

suppose I have this code:

class D : public Base1, Base2 {}

My question is. Obviously class D is public derived from Base1, but what about Base2? Is is private derived? Or also public derived?

I checked some websites but I did no find article about this. thank you!

Upvotes: 1

Views: 86

Answers (4)

Cody
Cody

Reputation: 3764

If I remember correctly Base2 is private by default however you can specify access for that one as well, as in this example:

class D : public Base1, public Base2 {};

Upvotes: 0

Sadiq
Sadiq

Reputation: 2289

Private. Unless it's declared as public, it will always be private by default.

Upvotes: 0

Mahesh
Mahesh

Reputation: 34665

Class members are private by default and that holds for inheritance too. Also, class definition should end with a ;.

Upvotes: 3

Tamer Shlash
Tamer Shlash

Reputation: 9523

It's private derived, inheritance method should be declared for each base class individually, if not, then it's private by default.

Upvotes: 3

Related Questions