Answer to Question #251738 in C++ for Gulli

Question #251738
Q2: Answer the questions (i) to (iv) based on the following:
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();
};
i. Write the names of data members, which are accessible from objects belonging to class Author.
ii. Write the names of all the member functions which are accessible from objects belonging to class Branch.
iii. Write the names of all the members which are accessible from member functions of class Author.
iv. How many bytes will be required by an object belonging to class Author?
1
Expert's answer
2021-10-16T17:23:12-0400

1) no data members can be accessed with following syntax:

Author a;

a.<data_member>

2) no data members

3) acode; aname; amount; employees

4) Required:

32 + sizeof(Branch) + sizeof(Publisher) = 80 bytes

-------------------

sizeof(Branch) = 24

sizeof(Publisher) = 24

calculated base on alignments of data members on my x64 machine.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS