Mail Archives: djgpp/1996/12/23/10:53:59
> I agree this time. The speed of compiled C++ code depends on the
> complexity of your class hierarchies. Overloading, lots of virtual
> functions, copy constructors and that sort of things are
> slow-downers.
Copy constructors are the big hits. Pay careful attention to these!
Virtual functions add only a few cycles per call (two pointer
dereferences and an add, I think), regardless of your class structure.
Function overloading is done at compile time and does not incur a
runtime hit.
> Most C/C++ compilers however allow C and C++ code to be mixed. It
> won't hurt to use C++ code in your C program or vise versa, as long
> as you keep an eye on performance.
For example, I write in C++ most of the time (djgpp is an exception),
but I always use printf instead of cout (for various reasons).
> But hey, if you really want fast code, you should be concerned about
> efficient software design, optimizing algorithms and clever data
> structures.
Two other concerns that C++ addresses is;
1) The code is easier to design and write when you have appropriate
tools.
2) Cleaner designs result in easier maintenance.
I've also noticed that if you can come up with a cleaner design, you
can often *reduce* the amount of code needed to run it.
- Raw text -