What kind of object is p? Is there a difference in meaning in c# and C++ or the declaration has the same meaning in these lang.? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What kind of object is p? Is there a difference in meaning in c# and C++ or the declaration has the same meaning in these lang.?

class parent { \\code } class child : parent { \\code } main function { parent p= new child(); }

3rd Apr 2017, 11:42 PM
Husseiny
Husseiny - avatar
1 Answer
+ 2
They are different languages and they have different inheritance behavior. C++ can inherit from multiple C# can inheritance from only one base Class. p is a Child type. https://code.sololearn.com/c1hQM8ieJW8c/?ref=app This is wht I tried with C++ (I'm not good @ C++) p is a parent https://code.sololearn.com/cFGba0Y4878i/?ref=app
4th Apr 2017, 2:36 AM
Eranga
Eranga - avatar