I wanted to ask that at the last as the teacher said that a class variable will take memory only if an object is created but before creating the object also I am getting the size of the car i.e 28
As i have run a code on my sublime I am confused
hi @jsn853, when a datatype(be it custom like class and structure or provided ) is passed to sizeof operator it outputs the sizeof object of the datatype .that’s why computing something like sizeof(int) is possible
you can check by computing the sizeof object and class itself both will be same
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.