I have written this small program:
#include <iostream>
using namespace std;
class a{
};
int main ()
{
a *obj=new a();
cout<<sizeof(obj)<<endl;
cout<<sizeof(*obj)<<endl;
delete obj;
}
Below is the output that i have got:
> ./a.out
4
1
>
I can understand that its using 4 bytes for storing the address of the object. But what i dont understand is that 1 byte. since its an empty class i have got a doubt of what is the purpose of that 1 byte(size of the object).
My second question is will the default constructor be called? if yes what would it basically do?