| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1597 人关注过本帖
标题:这么多错误??????
取消只看楼主 加入收藏
幽灵嫖客
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-1-15
收藏
 问题点数:0 回复次数:3 
这么多错误??????

这是头文件:
#include <iostream>
using namespace std;
#ifndef COMPLEX0_H_
#define COMPLEX0_H_
class complex
{
private:
double real;
double imaginary;
public:
complex(double r=0.0,double i=0.0);
complex opreator+(const complex & c)const;
complex opreator*(const complex & c)const;
friend complex opreator*(double x,const compelx & c );
}
#endif
下面是成员函数的实现文件:

#include <iostream>
using namespace std;
#include "complex0.h"
complex::complex(double r=0.0,double i=0.0)
{
real=r;
imaginary=i;
}
complex complex::opreator+(const complex &c)const
{
return complex(real+c.real,imaginary+c.imaginary);
}
complex complex::opreator*(double x)const
{
return complex(real*x,imaginary*x);
}
complex opreator*(double x,const complex &c)
{
return c*x;
}

这只是一部分功能,就编译这些错误就一大堆,比如:
:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(12) : error C2143: syntax error : missing ';' before '+'
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(12) : error C2460: 'opreator' : uses 'complex', which is being defined
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(6) : see declaration of 'complex'
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(12) : error C2059: syntax error : '+'
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(12) : error C2238: unexpected token(s) preceding ';'
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(15) : error C2143: syntax error : missing ';' before '*'
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(15) : error C2460: 'opreator' : uses 'complex', which is being defined
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(6) : see declaration of 'complex'
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(15) : error C2086: 'opreator' : redefinition
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(15) : error C2062: type 'double' unexpected
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(15) : error C2238: unexpected token(s) preceding ';'
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(16) : error C2143: syntax error : missing ';' before '*'
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(16) : error C2460: 'opreator' : uses 'complex', which is being defined
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(6) : see declaration of 'complex'
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(16) : error C2433: 'opreator' : 'friend' not permitted on data declarations
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(16) : error C2244: 'opreator' : unable to resolve function overload
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(16) : error C2062: type 'double' unexpected
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(16) : error C2238: unexpected token(s) preceding ';'
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(5) : error C2533: 'complex::complex' : constructors not allowed a return type
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(5) : error C2572: 'complex::complex' : redefinition of default parameter : parameter 2
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(11) : see declaration of 'complex::complex'
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(5) : error C2572: 'complex::complex' : redefinition of default parameter : parameter 1
d:\vc++ 6.0\msdev98\myprojects\my c plus\类\complex0.h(11) : see declaration of 'complex::complex'
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(9) : error C2143: syntax error : missing ';' before '+'
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(9) : error C2350: 'complex::opreator' is not a static member
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(9) : error C2264: 'complex::complex' : error in function definition or declaration; function not called
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(9) : error C2143: syntax error : missing ';' before '+'
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(10) : error C2143: syntax error : missing ';' before '{'
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(10) : error C2447: missing function header (old-style formal list?)
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(21) : error C2143: syntax error : missing ';' before '*'
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(21) : error C2350: 'complex::opreator' is not a static member
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(21) : error C2264: 'complex::complex' : error in function definition or declaration; function not called
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(21) : error C2062: type 'double' unexpected
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(22) : error C2143: syntax error : missing ';' before '{'
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(22) : error C2447: missing function header (old-style formal list?)
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(25) : error C2143: syntax error : missing ';' before '*'
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(25) : error C2264: 'complex::complex' : error in function definition or declaration; function not called
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(25) : error C2062: type 'double' unexpected
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(26) : error C2143: syntax error : missing ';' before '{'
D:\VC++ 6.0\MSDev98\MyProjects\My C Plus\类\complex0.cpp(26) : error C2447: missing function header (old-style formal list?)
执行 cl.exe 时出错.

complex0.obj - 1 error(s), 0 warning(s)

各位帮我看看,谢谢了!

搜索更多相关主题的帖子: complex double const std opreator 
2007-05-05 06:10
幽灵嫖客
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-1-15
收藏
得分:0 
回复:(幽灵嫖客)这么多错误??????
错误多,好像很多相似的!

C primer plus
2007-05-05 06:13
幽灵嫖客
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-1-15
收藏
得分:0 

郁闷亚,看起来挺简单的!做起来就不一样了!


C primer plus
2007-05-05 14:48
幽灵嫖客
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-1-15
收藏
得分:0 

各位见笑了!


C primer plus
2007-05-05 23:15
快速回复:这么多错误??????
数据加载中...
 
   



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

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