Hi,
When I I tried to determine the size of static data member and found the size of class was 1. Could anyone explain the reason?.
#include<iostream>
using namespace std;
class sample
{
static int data;
};
int sample:: data =10;
int main()
{
cout<<sizeof(sample)<<endl;
return 0;
}
output :1
I was expecting 4 on the linux machine. any pointer
sizeof(sample)
operator returns the size that an object of type sample would have
Functions and static members don't modify it