5 ms·
There 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
by DarkShikari 18y ago
There 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