Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

implementing OO concepts in C 1

Status
Not open for further replies.

sachindn

Programmer
Jun 27, 2000
10
US
Hi All,
can somebody give me any idea for implementing polymorphisam and virtual functions in C
Thanks
 
Here Ion writes something about object creation/deletion:

Regarding polymorphism - I'm not sure, but virtual functions in C++ are realized through tables of pointers to "callback" functions of methods. These pointers are filled out during object creation. In C you can go the same way - use pointers to functions as members of structure of base class.
Different interfaces to inherited class (multiple base classes with virtual functions) can be realized using multiple sets of pointers to implementation functions. So, if you want to use multiple interfaces, access these tables not directly, but through pointers to each base class layout, located at very begin of the inherited class layout.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top