std::ifstream & operator >> (std::ifstream & in , Table &tab)
{
in >> tab.table_no;
in >> tab.table_type;
return in;
}
std::ofstream & operator << (std::ofstream & out, const Table &tab)
{
out << tab.table_no;
out << tab.table_type;
return out;
}
When i compile the above code i get the following error...
table.hpp: In function ‘std::ifstream& operator>>(std::ifstream&, Table&)’:
table.hpp:19:7: error: ‘int Table::table_no’ is private
table.cpp:91:12: error: within this context
table.hpp:20:15: error: ‘std::string Table::table_type’ is private
table.cpp:92:12: error: within this context
table.hpp: In function ‘std::ofstream& operator<<(std::ofstream&, const Table&)’:
table.hpp:19:7: error: ‘int Table::table_no’ is private
table.cpp:98:13: error: within this context
table.hpp:20:15: error: ‘std::string Table::table_type’ is private
table.cpp:99:13: error: within this context
Please help me to fix this error.. Thanks in advance
Hi MiiNiPaa..
i can't write the programme of object oriented programming by operator overloading...
teacher has given me the assignment of operator overloading using string, in which we have to use (+,-,<,> and = operators)..so in (+) operator we have to add the two names like joseph+sam= joseph sam.. and in (-) operator we have to minus the names like adam - sam= dm, means only we have to minus the same letters..and in other operator we have to just assign like adam=sam and adam< sam...i hope u will understand what i am trying to say...please help me if u can.. thank you...thisis my ID plz contact me on it...awais4823@gmail.com or awaiskhan1k@yahoo.com