标题:[求助]运算符重载错误
取消只看楼主
luckylock
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-3-20
 问题点数:0 回复次数:1 
[求助]运算符重载错误

class complex//complex.h
{ int mi,mj;
public:
complex();
complex(int i,int j);
friend complex operator +(complex& x,complex& y);
friend complex operator -(complex& x,complex& y);
display();
};

#include "complex.h"//complex.cpp
#include <iostream.h>
#include "stdio.h"
complex::complex()
{mi=mj=0;
}
complex::complex(int i,int j)
{ mi=i;
mj=j;
}

complex::display()
{
cout<<mi<<"\t"<<"+"<<"\t"<<mj<<"i"<<endl;
}
complex operator +(complex& x,complex& y)
{ complex res;
res.mi=x.mi+y.mi;
res.mj=x.mj+y.mj;
return res;
}
complex operator -(complex& x,complex& y)
{ complex res(x.mi-y.mi,x.mj-y.mj);
return res;
}
void main()
{ complex x(1,2);
complex y(3,4);
complex a,b;
a=x+y;
b=x-y;
a.display();
b.display();
}

错误信息:unresolved external symbol _WinMain@16
1 unresolved externals

搜索更多相关主题的帖子: complex 运算符 int operator 
2006-03-28 01:05
luckylock
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-3-20
得分:0 
3楼正解,谢了。

编程之道千千万,立志成才路路通。
2006-03-28 12:48



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-53292-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.559417 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved