kagali-san
kagali-san

Reputation: 3082

C# vs C++: inheritance specifics

What can be counted as a visible difference between C# and C++ OOP standard definitions? I'm especially interested in anything related to visibility of overloaded/overrided methods.

It seems that C# implements a subset of C++ inheritance order based of stack call order in a class chain; Is that true? Or C# OOP is something different from C++? (Of course, C# has native reflection support, but I'm more interested in finding issues related to inheritance or, probably, compositing).

Is there a well-known situation, in which class N: .. class B: A { } in C++ can't access the base class data (under any possible conditions) that is possible in C#?


I am strongly against recognizing this question as "already answered". Nothing on 'internal' was said, abstract classes can't be clearly evaluated to C++ protected constructor / virtual constructor classes (and the whole interface thing is different with C++). Thus, please don't close the bounty if I have the chance to open it - there surely must be more differences.

Upvotes: 0

Views: 1559

Answers (2)

gleng
gleng

Reputation: 6304

I'm sure you can find a whole book on this stuff. One big change is when defining a class in C#, you can only inherit from one base class. C++ you can inherit from multiple.

Is there a well-known situation, in which class N: .. class B: A { } in C++ can't access the base class data (under any possible conditions) that is possible in C#?

If the base class is protected or public.

The protected keyword is a member access modifier. A protected member is accessible within its class and by derived class instances. (Source: http://msdn.microsoft.com/en-us/library/bcd5672a.aspx)

Upvotes: 2

user2711965
user2711965

Reputation: 1825

c++ supports Multiple inheritance, whereas C# doesn't that is probably the biggest differences.

Upvotes: 2

Related Questions