Memory allocation for member functions in C++

前端 未结 4 429
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-09 19:47
#include
using namespace std;
class A
{

};
class B
{
        public:
                void disp()
                {
                        cout<&         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 20:13

    Size of any class depends upon the size of the variables in the class and not the functions. Functions are only allocated space on the stack when called and popped out when return.. So the size of a class is generally the sum of sizes of non static member variables...

提交回复
热议问题