- #1
Dissident Dan
- 238
- 2
I'm wondering what the performance differences are between using C and C++. I think that it's quite clear that large C programs will generally run faster that large C++ programs, but how much so, and what factors have what effect?
For example:
I would assume minimal or no effect in the following areas:
-Using member functions as opposed to passing a struct as a pointer (and possibly using member function pointers)
moderate effect
-(non-inhereted) constructors
Large effect
-Real-time time checking for virtual functions (polymorphic method invocation)
-Real-time typecast type-checking (not sure if C++ does this. I know java does)
-Multiple constructors
-new/delete as opposed to malloc()/free()
-streams as opposed to FILE*, etc.
Not sure
-Multiple inheritance of functions
-Multiple inheritance of variables
-effects of different data/program organization
-Operator overloading (as opposed to function calls)
-Argument (parameter) pass by reference (ampersand) as opposed to pointer
This may actually provide an advantage to C++
-Compiler (C++ compilers are probably newer, having more optimizations)
What would be the performance effect of writing a .cpp file using only C code (so that a c++ compiler is used on the c code)?
For example:
I would assume minimal or no effect in the following areas:
-Using member functions as opposed to passing a struct as a pointer (and possibly using member function pointers)
moderate effect
-(non-inhereted) constructors
Large effect
-Real-time time checking for virtual functions (polymorphic method invocation)
-Real-time typecast type-checking (not sure if C++ does this. I know java does)
-Multiple constructors
-new/delete as opposed to malloc()/free()
-streams as opposed to FILE*, etc.
Not sure
-Multiple inheritance of functions
-Multiple inheritance of variables
-effects of different data/program organization
-Operator overloading (as opposed to function calls)
-Argument (parameter) pass by reference (ampersand) as opposed to pointer
This may actually provide an advantage to C++
-Compiler (C++ compilers are probably newer, having more optimizations)
What would be the performance effect of writing a .cpp file using only C code (so that a c++ compiler is used on the c code)?