在c ++中使用类方法覆盖运算符

时间:2014-10-10 11:18:20

标签: c++ operator-overloading

有没有办法通过使用其他类方法(如read()和write()来覆盖像<<>>这样的流运算符?

例如,

//In the header file
class Customer
{
    void read(istream &, Customer &);
    istream & operator>>(Customer &) = read();

    void write(ostream &, const Customer &);
    ostream & operator<<(const Customer &) = write();
}

这是教科书中问题的请求功能,不允许friend

0 个答案:

没有答案