Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

If you were to extend C with some OO elements

Name: Anonymous 2009-12-02 16:50

Not that there would be much point doing that and not just using a different language.
But I thought a little about things like classes with single inheritance (achieved by replicating the same code in the inheriting class as in the base one), and I wonder about ways to implement virtual functions. I thought that for each vfunction you could just store its pointer as an additional member, but then with multiple members a vtable would make for more efficient storage. And also, I could replace the vtable pointer with a pointer to some kind of a type descriptor (which would then have the vtable), and add some type of reflection.
But the latter two methods would have to add some kind of a ``hidden'' field to the struct, while in the first one the count and location of those fields would be predictable. If I went with the ``hidden pointer'' approach, I would then need to adjust pointers behind the scenes and some other shit. I wonder how C++ does this?

Also, your thoughts. And keep in mind that I'm not some kind of EXPERT LANGUAGE DESIGNER (at least not yet), so don't get too mad.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List