IT Community - Software Programming, Web Development and Technical Support

simulating OOP-style inheritance in C?

This is a discussion on simulating OOP-style inheritance in C? within the C and C++ Programming forums, part of the Software Development category; Hi, Can anyone tell me if there is a good way of simulating OOP-style inheritance, or other OOP features, ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C and C++ Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-18-2007, 02:52 AM
prasath prasath is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Location: Chennai
Posts: 173
prasath is on a distinguished road
Smile simulating OOP-style inheritance in C?

Hi,

Can anyone tell me if there is a good way of simulating OOP-style inheritance, or other OOP features, in C?

Thanks,
Prasath.K

Last edited by Booom : 08-18-2007 at 01:11 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-18-2007, 12:40 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: Is there a good way of simulating OOP-style inheritance, or other OOP features, i

hey,

It's straightforward to implement simple "methods" by placing function pointers in structures. You can make various clumsy, brute-force attempts at inheritance using the preprocessor or by having structures contain "base types" as initial subsets, but it won't be perfect. There's obviously no operator overloading, and overriding (i.e. of "methods" in "derived classes") would have to be done by hand. Obviously, if you need "real" OOP, you'll want to use a language that supports it, such as C++
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
style:z-Index varghese HTML, CSS and Javascript Coding Techniques 2 09-03-2007 01:01 AM
How do you create multiple inheritance in c# and .NET? vadivelanvaidyanathan C# Programming 3 07-20-2007 07:54 AM
What are some alternatives to inheritance? prasath Java Programming 1 07-20-2007 06:49 AM
Why multiple inheritance cant support in java leoraja8 Java Programming 2 07-16-2007 11:34 PM
Inheritance Class in C++ vigneshgets C and C++ Programming 1 05-23-2007 12:00 PM


All times are GMT -7. The time now is 08:12 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0