Reputation: 10830
Does C support inheritance? If so, is it by using struct
s since classes are not defined in C?
Upvotes: 5
Views: 5618
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
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
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