Saturday, 31 August 2013

why size of a class is zero in this case and how we ensure different objects have different address

why size of a class is zero in this case and how we ensure different
objects have different address

i create a clss bt its size is zero .now how can be ensure that object
have different addresses as wwe know empty class have non zero size to
ensure that
`#include<cstdio>
#include<iostream>
using namespace std;
class Test
{
int arr[0];//why size is zero?
};
int main()
{
Test a,b;
if (&a == &b)// now how we ensure about address of objects ?
cout << "impossible " << endl;
else
cout << "Fine " << endl;//why address is nt same?
return 0;
}`

No comments:

Post a Comment