#include <iostream>
#include <string>
class TOperator {
private:
string name;
public:
TOperator(string name) { this->name = name; }
TOperator();
void setName(string name) { this->name = name; }
string getName { return name; }
};
class TComanda {
private:
Item *I = new Item[1];
int count;
string status;
public:
TComanda(string status) { this->status = status; }
TComanda();
void setSatus(string status) { this->status = status; }
string getStatus { return status; }
TComanda operator+=(string, const TOpeator &op) {
TComanda result;
result.name = name += op.name;
result.status = status += op.status;
}
};
class Item {
private:
string object;
int price;
public:
Item(string object, int price) {
this->object = object;
this->price = price;
}
Item();
void setObject(string object) { this->object = object; }
string getObject { return objectt; }
oid setPrice(int price) { this->price = price; }
string getPrice { return price; }
};
int main() {
TOperator oper("Alex");
TComanda command("online", oper);
command += Item("usb stick", 220);
command += Item("keyboard", 175);
oper.displayCommanda();
return 0;
}
So i have the main and then I have to create all the classes and functions for it to work, I'm not really sure how to I overload the += for it to work, I'm kinda new in C++ and this comes very heavy for me, can someone please explain how do I overload the += so that in the display I have "Alex online, usb stick, 220" for example
Also this sequence is not done by me and I'm not sure it does what I want, I'm pretty sure it's wrong but I don't know why
TComanda operator+=(string, const TOpeator &op) {
TComanda result;
result.name = name += op.name;
result.status = status += op.status;
}