关于函数重载运算问题。。。急

来源:百度知道 编辑:UC知道 时间:2024/04/30 09:32:29
在下面程序中,类three_d重载了运算符“《”和“》”使用一个用户自定义运算符函数数据写到屏幕上或文件中。
class three_d{
private:
int a,b,c;
}

求高手写下程序。。。急,。。
要用 C++

#include "iostream"
#include "cstdlib"
using namespace std;
class three_d
{
private:
int a;
int b;
int c;
public:
three_d();
three_d(int i,int j,int k);
friend ostream & operator<<(ostream & os, const three_d & t);
friend istream & operator>>(istream & is, three_d & t);
};

three_d::three_d()
{
a=b=c=0;
}

three_d::three_d(int i,int j,int k)
{
a=i;
b=j;
c=k;
}

ostream & operator<<(ostream & os, const three_d & t)
{
os << "a=" << t.a << endl
<< "b=" << t.b << endl
<< "c=" << t.c << endl;
return os;
}

istream & operator>>(istream & is, three_d & t)
{
cout << "Please enter three integers: ";
is >> t.a