Question & Answer: Consider the following struct declarations:…..

Consider the following struct declarations:

struct SupplierType

{
string name;
int supplierID;

};

struct ApplianceType

{
SupplierType supplier;
string modelNo;
double cost;

};

Write C++ statements to do the following:

1) declared a pointer variable p to point at data of type ApplianceType (3 pts),

2) create a dynamic data of type ApplianceType and store its address in p (3 pts), and

3) assign the value “Apple Inc” to the name of the supplier of the data pointed at by p (4 pts).

Expert Answer

 

The answers to the question are given below. Please rate the answer if it helped. Thank you.

1) ApplianceType *p; //declare a pointer to point to ApplianceType
2) p = new ApplicanceType; //create a dynamic data of ApplianceType and store it in p
3) p->supplier.name = “Apple Inc”; //assign value to supplier name

Still stressed from student homework?
Get quality assistance from academic writers!