Placement new... But then again, who likes to explicitly call a destructor?
Example:
Code:int *x = new(malloc(sizeof(*x))) int; // At which point this line is perfectly acceptable free(x);
Placement new... But then again, who likes to explicitly call a destructor?
Example:
Code:int *x = new(malloc(sizeof(*x))) int; // At which point this line is perfectly acceptable free(x);
It doesn't really matter what the contents is in a header. The extension is optional. You can use .h in C++, as well as C. I wouldn't say it's wrong or bad practice.
And especially in C++, I would avoid saying "passing by reference" if you aren't actually doing it (ie passing by pointer), because in C++ there are references and pointers.
But you should really try out templates, at the very least. Very powerful stuff right there.
I suspect that samGwilliam is referring to a habit of including the C standard headers instead of their C++ versions.Originally Posted by Elysia
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)