Programming Basic--what is the output of the following code?
#include "iostream"
#include"string.h"
#include "stdio.h"
class A{
};
class A2{
char d,e;
};
struct B{
};
struct C{
char b,c;
};
struct D{
int x,y;
};
int main()
{
count<<sizeof(A)<<endl;
cout<<sizeof(A2)<<endl;
A *p1=new A();
A *p2;
A *p3;
cout<<sizeof(p1<<endl;
cout<<sizeof(p2)<<endl;
cout<<sizeof(p3)<<endl;
cout<<sizeof(B)<<endl;
cout<<sizeof(C)<<endl;
cout<<sizeof(D)<<endl;
return 0;
}
Answer:
1,2,4,1,4,1,2,8
#include"string.h"
#include "stdio.h"
class A{
};
class A2{
char d,e;
};
struct B{
};
struct C{
char b,c;
};
struct D{
int x,y;
};
int main()
{
count<<sizeof(A)<<endl;
cout<<sizeof(A2)<<endl;
A *p1=new A();
A *p2;
A *p3;
cout<<sizeof(p1<<endl;
cout<<sizeof(p2)<<endl;
cout<<sizeof(p3)<<endl;
cout<<sizeof(B)<<endl;
cout<<sizeof(C)<<endl;
cout<<sizeof(D)<<endl;
return 0;
}
Answer:
1,2,4,1,4,1,2,8