Saturday, May 22, 2010

What kind of code or lib sets up OOP? Specifically what is the “Overhead” that make C++ bigger than C ?

Have taken a few entry-level C++ programming classes at the local Junior college, NP. Then aced my assembly languange/MCU classes after that. But neither teacher talked about how OOP is set up. One said "you don't need to know the tiny details" the other said, "that's too far ahead of this class" So there is a gap in my understanding of how it all fits together. Is there anyone out there who can explain where/how C++ splits from C down at the register level?

What kind of code or lib sets up OOP? Specifically what is the “Overhead” that make C++ bigger than C ?
C++ calls have one extra address load, so they are not a big deal.





C++ does like to do a lot of data copying though, especially with strings where it likes to reallocate memory from the heap everytime you do something with a string (append or concatenate for example).





Other than that, it does not do much, if any, damage to your execution time. Most of the libraries in common are the same (floating point is floating point).





Some of the simpler OO stuff can be thought of as "structs with function pointers", but this is only true with very simple classes and breaks when you do inheritance.





You can compile c++ code through assembly and inspect the assembly listings (don't know if Windows C++ does this, but gnu and mingw32 will do it).


No comments:

Post a Comment