ckv
ckv

Reputation: 10830

Does C support inheritance?

Does C support inheritance? If so, is it by using structs since classes are not defined in C?

Upvotes: 5

Views: 5618

Answers (4)

Midhat
Midhat

Reputation: 17820

No, it doesn't. 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.

Upvotes: 8

swestrup
swestrup

Reputation: 4209

There is no Compiler-level support for inheritance in C. Nevertheless, as others have already pointed out, Object Oriented coding does not REQUIRE such support. However, its a lot easier to write OO code in C++.

Upvotes: 5

Yktula
Yktula

Reputation: 14819

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? .

Upvotes: 12

SLaks
SLaks

Reputation: 887767

No, it doesn't.

Upvotes: 6

Related Questions