Memory allocation for member functions in C++

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

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


        
4条回答
  •  臣服心动
    2020-12-09 20:07

    Non-virtual functions aren't part of the class's memory. The code for the function is baked into the executable (much like a static member), and memory is allocated for it's variables when it is called. The object only carries the data members.

提交回复
热议问题