Size of the Object in C++

In a C++ programming language,  size of any object is equal to the sum of size of all the data members of the class.

In a below program,  class contain three data type and three variable. 

Data type int occupies 4 bytes, float occupies 4 bytes, and char occupies 1 byte. their sum is  9 bytes .

In this program size of individual of object is 9 byte. We can know the size of object/class by using  sizeof() operator.


Categories C++