sizeof class with int , function, virtual function in C++?

前端 未结 5 1880
夕颜
夕颜 2020-11-29 21:39

This is an online C++ test question, which has been done.

#include
using namespace std; 
class A
{

};
class B
{
int i; 
}; 

class C
{
void         


        
5条回答
  •  鱼传尺愫
    2020-11-29 22:27

    Size of int with padding and the virtual function =18 bytes

    simple function bytes =1 virtual function =8

    And you cant simply add all the bytes there is concept of padding check it out on google.

    Declaring in different order change the size of class

提交回复
热议问题