Answer to Question #230076 in C++ for mahnoor

Question #230076

Create a class Lab which will have the objects from the class Computer which will further carries the object of another class named Accessories

 

Write required methods and attributes with in the class implementation.

 

Using the knowledge from above relationships complete your implementation.


1
Expert's answer
2021-08-27T02:04:17-0400


#include <iostream>


using namespace std;
class Accessories{
    private:
        int acc_id;
        string acc_name;
    public:
        void setAccID(int i){
            acc_id=i;
        }
        void setAccName(string n){
            acc_name=n;
        }
        int getAccID(){
            return acc_id;
        }
        string getAccName(){
            return acc_name;
        }
};


class Computer{
    public:
        Accessories a;
};
class Lab{
    public:
        Computer c;
};




int main()
{
    Accessories a1;
    Computer c1;
    Lab l1;
    return 0;
}

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