Bytes

Questions is How many bytes will be required by an object belonging to class AUTHOR? and how this is calculated?

class PUBLISHER
{
char Pub[12];
double Turnover;
protected:
void Register();
public:
PUBLISHER();
void Enter();
void Display();
};
class BRANCH
{
char CITY[20];
protected:
float Employees;
public:
BRANCH();
void Haveit();
void Giveit();
};
class AUTHOR : private BRANCH , public PUBLISHER
{
int Acode;
char Aname[20];
float Amount;
public:
AUTHOR();
void Start();
void Show();
}
Depends on compiler and aliasing settings.
This is also one question in exam... answer is 70... how to find it out...
On my machine sizeof(AUTHOR) is 80, not 70. It depends on compiler and its aliasing settings. Size will not be same for all. So not only code in invalid (missing semicolon in class declaration), but whole question is incorrect. All one is able to say is that AUTHOR class cannot be less that 68 bytes (sum of sizes of all its components). Whoever wrote your questions is clearly incompetent.
Topic archived. No new replies allowed.