Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does C language support inheritance?

Tags:

c

oop

inheritance

Does C language support inheritence. If so is is it using structures as classes are not defined in C.

like image 519
ckv Avatar asked Jun 06 '10 19:06

ckv


People also ask

Why inheritance is not possible in C?

C# compiler is designed not to support multiple inheritence because it causes ambiguity of methods from different base class. This is Cause by diamond Shape problems of two classes If two classes B and C inherit from A, and class D inherits from both B and C.

Can we inherit structure in C?

No you cannot. C does not support the concept of inheritance.

Which programming language does not support inheritance?

Which language does not support all 4 types of inheritance? Explanation: Java doesn't support all 4 types of inheritance. It doesn't support multiple inheritance. But the multiple inheritance can be implemented using interfaces in Java.

Does C have multiple inheritance?

Master C and Embedded C Programming- Learn as you go So the class can inherit features from multiple base classes using multiple inheritance. This is an important feature of object oriented programming languages such as C++.


2 Answers

Yes, it does. See http://gcc.gnu.org/ml/gcc/2010-05/msg00725.html . See Axel-Tobias Schreiner's book Object-Oriented Programming with ANSI C. There's an English translation of it available.

Also, see Object-orientation in C and How can Inheritance be modelled using C? .

like image 129
Yktula Avatar answered Oct 06 '22 23:10

Yktula


No it doesnt. C is not an Object Oriented language. Inheritance is a property of OO languages.

You should try C++. It's OO and supports much more than inheritance

like image 37
Midhat Avatar answered Oct 07 '22 00:10

Midhat