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, ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| 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. |
| Sponsored Links |
| |||
| 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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |
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 |