> It's only when you need protection and class heirarchies that C++ benefits you.
Well, need is a strong word. You might not need better correctness while still coming out way ahead by using C++.
Well, need is a strong word. You might not need better correctness while still coming out way ahead by using C++.
http://www.geeksforgeeks.org/virtual-functions-and-runtime-p...
struct A { int x; };
struct B : A { int y; };
is the same as if you had written struct B { int x; int y; };
Public/private/protected inheritance and access control do not add overhead. It's literally only if you opt in by typing `virtual` do you get class hierarchy overhead.That's interesting. So does the compiler just put the functions in different parts of the vtable to remember the access control rules. There's no such thing as a free lunch and you're adding information here -- has to be stored somewhere.