c++ - Size of a class with only one function which do not have body -
this question has answer here: sizeof class int , function, virtual function in c++? 4 answers i have been asked question size of below give class: class { void abc(); } and if make function virtual size now class { virtual void abc(); } note: question in respect visual studio compiler. i told first have 1 byte , second have 5 bytes compiler adds v pointer second. i check on visual studio 2010 in 64 bit machine:- the size of class in first case 1 byte , in second case 4 byte.i play around , found below results putting in questions: i found if class have functions in it(with body or without) , no data members, size of class 1 byte , object created have size 1 byte below example: class myclass { void abc(){int x=0;} int getdouble(int y){return y*2;} }; int main() { myclass obj;; std::cout<<sizeof(myclass )<<"\n...