S
Salman
I want to know abt the size of the class using sizeof function. i have
pasted 2 programs. Both gives different sizes of the class just by re-
arranging the order of the private varibles. Tell me whats the reason
behind it. Im pasting both the programs. I using VC++ 6
---------------Program 1 ----------------------------
#include <iostream>
using namespace std;
class A {
char a;
char b;
int* c;
};
int main(void) {
A a;
cout<<sizeof(a);
return 0;
}
---------------Program 2 ----------------------------
#include <iostream>
using namespace std;
class A {
char a;
int* c;
char b;
};
int main(void) {
A a;
cout<<sizeof(a);
return 0;
}
pasted 2 programs. Both gives different sizes of the class just by re-
arranging the order of the private varibles. Tell me whats the reason
behind it. Im pasting both the programs. I using VC++ 6
---------------Program 1 ----------------------------
#include <iostream>
using namespace std;
class A {
char a;
char b;
int* c;
};
int main(void) {
A a;
cout<<sizeof(a);
return 0;
}
---------------Program 2 ----------------------------
#include <iostream>
using namespace std;
class A {
char a;
int* c;
char b;
};
int main(void) {
A a;
cout<<sizeof(a);
return 0;
}