রবিবার, ২ ডিসেম্বর, ২০১২

c++ - Ostream from multiple classes - Stack Overflow

I seem to be getting the Error C2440: 'return' cannot convert from 'LinkList' to 'Tray *'. What i'm trying to do is add the output of a second class to that of the customer class. So if i was to call a method such as whoIsEating() i could easily get a list of who, where and what. I had an idea of using 'friend' but i'm quite unsure on that.

Customer.h

class Customer { private:     int tableNumber;     std::string firstName;     std::string lastName;     LinkList<Tray> *myTray; public:     Customer();     Customer(std::string sFirstName, std::string sLastName,         int sTableNumber,         LinkList<Tray> *myTray = new LinkList<Tray>());     ~Customer(void);      int gettableNumber();     Tray* getTray(void); 

Customer.cpp

Tray* Customer::getTray() {     return *myTray; }  ostream& operator << (ostream& output, Customer& customer) {     output << customer.getFirstName() << " " << customer.getLastName() << endl         << customer.gettableNumber() << endl         << (*customer.getTray()) << endl; //Edit: Fixed this     return output; 

Tray.cpp

ostream& operator << (ostream& output, Tray& tray) {     output << "Drink: " << tray.getdrink() << endl;     output << "Food: " << tray.getfood() << endl;     return output; } 

Suspected output would be like

Name: John Smith

Table Number: 12

Meal Details:

Drink: Tea

Food: Fish & Chips

Source: http://stackoverflow.com/questions/13663984/ostream-from-multiple-classes

anchorman 2 kentucky basketball oaksterdam the fray national anthem dallas tornado ncaa basketball oikos

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন