#include <iostream>
#include <string>
using namespace std;
class phonebook
{
string name;
string prefix;
public:
phonebook(string &name, string &prefix)
{
this->name = name;
this->prefix = prefix;
}
friend istream &operator>>(istream &in, phonebook &book);
};
istream &phonebook::operator>>(istream &in, phonebook &book)
{
in >> book.name >> book.prefix;
return in;
}
int main()
{
return 0;
}
当我尝试使用g++ 4.6.1编译此代码时:
"main.cpp:20: error: ‘std::istream& phonebook::operator>>(std::istream&, phonebook&)’必须只接受一个参数"
PS:这是一个相当愚蠢的问题...显而易见:S。不过还是谢谢你。