as it has been said that class does not take any space.
but this code is showing size of class as 28.
why
https://ide.codingblocks.com/s/53647
Doubt regarding size
data members that you used i.e price , model_no they use space when u declare object of class Car.
Yes , Class is just a way to (Programming paradigm -OOPS) wrap up data together and use as a single entity. And that can be done using objects/instance of the class.
but here I have not created any object still it is giving size.
if memory gets allocated only when object is created and here I have not created any object…so why is output
Hi Gaurav, the size that is being shown on output screen is the number of bytes Car class will take when an object of it is instantiated.