Quote:
Originally Posted by
core_cpp
Not to get off topic, but sheesh, what is with the "This is C, not C++" comments in 95% of the threads around here?
If you are a C++ dev, then you should be using C++ facilities instead of C facilities, 99% of the time.
Quote:
I'm with brewbuck. There are plenty of times you _need_ malloc.
There are never a time that you need to use malloc unless a library forces it upon you. Using new can--and is--identical to using malloc.
Quote:
Using malloc(), fgets(), or you name it does not make code C code. If I want a fast C++ application I am going to use fread() rather than ifstream. That does not make it a C application -- a C compiler would cough on it immediately.
No, it makes it C code or C+ code.
malloc and fgets are C relics and have no purpose in C++. The C++ is code is not, and I repeat it is NOT slower than the C equivalent.
Quote:
Who decided that if you're not using the latest and greatest features of a language it's suddenly not even valid code at all for the languge? Do I have to add a token class which does nothing to each of my sources just to appease somebody?
You do not have the use the latest and greatest functionality (if such were the case, everyone would be doing template meta programming), but there are some basic facilities that any C++ programmer is expected to use.
Quote:
In my mind, the second I use something that is only available in C++ and not C, then it is C++ source code.
That just adds to the argument that using fgets, malloc and things in C++ in C code.
Quote:
Originally Posted by
steve1_rm
Yes, I understand in C++ you would use new.
However, we are doing some low level stuff as the library we are using is written in C. And new was giving us some unexpected results.
How so?
new can do the exact same thing as malloc.