In: Computer Science
I. Create the class Item with the following members:
1. id, a protected variable of type int
2. name, a protected variable of type string
3. price, a protected variable of type double
4. a public non-default constructor which accepts three parameters
to initialize the variables above
5. a copy constructor
6. overload the = operator such that both operands are of type
Item
7. overload the = operator such that the right operand is of type
double. Assign the value of double to the price member
Thanks for the question, here is the class Item in C++
===============================================================
class Item{
protected:
int id; string name; double
price;
public:
Item(int id, string name, double
price);
Item(const Item& item);
void operator=(const Item&
item);
void operator=(double price);
};
Item::Item(int id, string name, double price):
id(id),name(name),price(price){}
Item::Item(const Item& item){
id = item.id; name = item.name;
price = item.price;
}
void Item::operator=(const Item& item){
id = item.id; name = item.name;
price = item.price;
}
void Item::operator=(double price){
this->price = price;
}
===============================================================