My question is related to C++ class definition. I understand that if there are many member variables existing in the class. The size of the class will increase. Increasing the number of class member functions, however, will not affect its size. However, I was wondering what is the major difference between a class with more member functions and a class with less member functions. Will it be possible that invoking a class with less member functions is much faster?
Share
No, the only kind of functions that make any difference at all this respect are the virtual ones, and they are significantly slower than the usual kind no matter how many you have. In all other cases the compiler knows exactly what code to run when a particular function is called, so it won’t have to do any search and the number of methods wouldn’t matter.