[求助]重载
为什么老是说我重载<<运算符错误?
ostream &operator<<(ostream &os,const Date &d)
{
os<<ye<<"/"<<mo<<"/"<<da<<endl;
return os;
}
std::ostream& Date::operator<<(std::ostream&, const Date&)' must take exactly one argument
为什么说只能一个参数?
#include <iostream>
using namespace std;
class stu
{
int x,y;
public:
stu(int m,int n):x(m),y(n){}
ostream &operator<<(ostream&os,const stu&s)
{os<<s.x<<endl<<s.y;return os;}
};
int main()
{
stu s(1,2);
cout<<s;
system("pause");
return 0;
}
这应该没错吧,但是还是不行,晕
我是XP的系统啊,虽然不是较新的版本,但怎么说也是32位,怎么会这样啊