此类的对象大小是多少

What is the size of objects for this class?

本文关键字:多少 对象      更新时间:2023-10-16
Class Time{ 
int hour, min, sec; 
Time(){}; 
Time(int h,int m, int s){ 
hour = h; 
min = m; 
sec = s; 
} 
void printTime(){ 
cout<<hr<<”:”<<min<<”:”<<sec; 
} 
} 

我只想知道这个类中对象的大小是多少?

我会尝试这样的事情:

Time timeObject;
int size = sizeof(timeObject);