What’s the default inheritance type when ‘struct’ derived from ‘class’?


Dose this piece of code compile?

class CBase
{
public:
	void b() {	}
};
struct CSub: CBase //default inheritance
{
};
void TestInheritance()
{
	CSub Sub;
	Sub.b();

}

Yes. The default inheritance is public as long as the derived is ‘struct’ regardless of base calss.

Advertisements
Comments are closed.
%d bloggers like this: