3 ms·
This seems to apply to just C++ actually. Can I really do anything similar in C? I'm not sure. The tutorial makes use of overloading operators new and delete w
by listic 18y ago
This seems to apply to just C++ actually.
Can I really do anything similar in C? I'm not sure. The tutorial makes use of overloading operators new and delete which (both operators and overloading feature) are only available in C++.
I think the title is misleading; as far as I know, term "C/C++" is a blanket and should be avoided.
- signa11 18y ago> This seems to apply to just C++ actually. why ? you can just as well create a cache of objects of a given type from within C, and use that for allocation/deallocation...
- corentin 18y agoWell, you can replace malloc() and friends.
- DarkShikari 18y agoThere is basically nothing you can do in C but can't do in C++; the overloading is basically syntactical sugar. In fact, there are things you can explicitly do in C but can't do in C++ (at least if you insist on doing them the "C++ way"). Example: as far as I know, C++ doesn't let you use virtual constructors; C can implement this through function pointers. Of course, if you treat C++ as a superset of C and just do things "the C way" in cases when "the C++ way" doesn't work, obviously C++ can do everything C can.
- huhtenberg 18y agoThe lack of an equivalent of offsetof in C++ is a real pity. This effectively prohibits using C-style data containers, whereby container's control data is embedded into the data instance itself. This sort of thing: struct record { int foo; int bar; ... list_item item; // keeps 'record' on some list tree_item item; // keeps 'record' on some tree }; There's no concise and memory-efficient way of doing the same in C++.
- scott_s 18y agoBoost.Intrusive: http://www.boost.org/doc/libs/1_35_0/doc/html/intrusive.html http://www.boost.org/doc/libs/1_35_0/doc/html/intrusive.html