Program-1
#include<iostream>
using namespace std;
class test
{
char name;
int data;
};
int main()
{
cout<<sizeof(test);
return 0;
}
Program-2
#include<iostream>
using namespace std;
class test
{
char *name;
int data;
};
int main()
{
cout<<sizeof(test);
return 0;
}
Why char increase the size of class even though its size is 1 byte. plz explain with example.
Aucun commentaire:
Enregistrer un commentaire