my freind on msn said sometimes its acceptable(he says he's much smarter than me at this) to sometimes use c code with c++
is this true and if so when but i dont think it is
my freind on msn said sometimes its acceptable(he says he's much smarter than me at this) to sometimes use c code with c++
is this true and if so when but i dont think it is
When you don't want to reinvent the wheel.Originally Posted by lilhawk2892
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Well, in almost all cases, C++ has an improved alternative to the original C method of getting something done. When programming in C++, I rarely find any need to use the C method to do anything. Keep in mind, much of the libraries used in C are still used in C++, for instance <cmath> and <cctype>. Now, if you're porting C code to a C++ program, it's generally fine to leave the C as C and just build the C++ around it so long as the C still works. As they say, if it isn't broken, don't fix it.Originally Posted by lilhawk2892
Sent from my iPadŽ
thanks im gonna show this to him see what he says
For many cases, yes, I'll agree. But there are libraries out there that are written in C: libcurl, SDL, pthreads, Win32 API, etc. Some of these have C++ wrappers/equivalents. And some of us use the C version anyways. I've intermixed C++ with all of the above libraries except pthreads (it's only a matter of time).Originally Posted by SlyMaelstrom
Mixing C libraries with C++ code is, imho, perfectly acceptable and good thing. Mixing C and C++ code together in the same project, eh, it's ok. But if you're the one writing it, you might as well take advantage of the features C++ gives you.
And the STL/C++ adds a lot of stuff to the binary. Especially when debugging - those suckers get big quick. (But with today's hard drives, this is moot. And it's debugging...) Though wxWindows is large no matter what...
Edit: Missed your comment about libraries... oh well. My 2cent.
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
Yeah, sometimes one uses C-style code when dealing with libraries or APIs that are written for C and C++ both. I'd never use C-style code within a C++ program in any other case, though. In general the C++ style is shorter and easier to understand.
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.