Why inheritance is not supported by structures??

Questions by divya_insearch

Showing Answers 1 - 21 of 21 Answers

Guest

  • Jan 22nd, 2007
 

What used to be a struct in original C language moved on to C++ and then C#. Although lot of class capabilities have been added into struct, its purpose is to just group together few fields and may optionally contain some methods for their manipulation. The inheritance is a powerful object oriented concept implemented through classes. Structures (struct) are not appropriate for replacement of classes, while classes could easily be used in place of structure. In fact, you can do virtually do any thing with classes -- structs are still around primarily for historic reasons.

  Was this answer useful?  Yes

Structure support only interface inheritance but it don't  implementation(class) inheritance. Most probably bcoz its language(C#) feature and avoided due to complexities arised implementing it.

  Was this answer useful?  Yes

LordAlex

  • Nov 6th, 2011
 

Value type cannot have a reference -it can be only boxed.
Question : How to implament the type casting operator for inherited structs?
Answer: Copy the part of the member fileds.
Hence, it can be considered like an object.

  Was this answer useful?  Yes

Mohammad Sharib Khan

  • Jan 7th, 2015
 

http://stackoverflow.com/questions/1222935/why-dont-structs-support-inheritance

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions