我这个程序没实现了,请大家帮忙指教一下如何在MAIN()函数里 把重载>>运算符的功能体现出来啊 写几行代码就可以了 谢谢大家了
#include<iostream.h>
class a
{
public:
a(){}
a(int _m):m(_m){}
friend ostream& operator << (ostream& out,const a& other)
{
out<<other.m;
return out;
}
friend istream& operator >> (istream& in,const a& other)
{
in>>other.m;
return in;
}
private:
int m;
};
int main()
{
a p(3);
cout<<p<<endl;
int i;
cin>>i;
a q;
cin>>q(4);
cout<<q;
return 0;
}