| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2573 人关注过本帖
标题:D:\NO2\point.cpp(20) : error C2084: function 'double __thiscall Point: ...
只看楼主 加入收藏
karlzhouzhi
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2005-12-25
收藏
 问题点数:0 回复次数:2 
D:\NO2\point.cpp(20) : error C2084: function 'double __thiscall Point::ang

我的class定义:#include<iostream.h>
#include<math.h>

class Point
{
public:
void Set(double ix,double iy);
double xoffset();
double yoffset();
double angle();
double radius();
protected:
double x;
double y;
};

成员函数定义:#include<iostream.h>
#include"point.h"
void Point::Set(double ix,double iy)
{
x=ix;
y=iy;
}

double Point::xoffset()
{
return x;
}

double Point::yoffset()
{
return y;
}

double Point::angle()
{
return(180/3.14159)*atan2(y,x);
}

double Point::radius()
{
return sqrt(x*x+y*y);
}
主函数:
#include<iostream.h>
#include"point.h"

void main()
{
Point p;
double x,y;
for(;;)
{
cout<<"Enter x and y:"<<endl;
cin>>x>>y;
if(x<0)
break;
p.Set(x,y);
cout<<"angle="<<p.angle()
<<",radius="<<p.radius()
<<",x offset="<<p.xoffset()
<<",y offset="<<p.yoffset()<<endl;
}
}
compile没问题
build后就出现问题了:D:\NO2\point.cpp(4) : error C2084: function 'void __thiscall Point::Set(double,double)' already has a body
D:\NO2\point.cpp(10) : error C2084: function 'double __thiscall Point::xoffset(void)' already has a body
D:\NO2\point.cpp(15) : error C2084: function 'double __thiscall Point::yoffset(void)' already has a body
D:\NO2\point.cpp(20) : error C2084: function 'double __thiscall Point::angle(void)' already has a body
D:\NO2\point.cpp(25) : error C2084: function 'double __thiscall Point::radius(void)' already has a body
Error executing cl.exe.

搜索更多相关主题的帖子: cpp ang double Point point 
2006-01-16 12:21
柳儿
Rank: 6Rank: 6
等 级:贵宾
威 望:25
帖 子:1830
专家分:30
注 册:2004-9-23
收藏
得分:0 
这三段代码分别放在三个文件里,没有发现错误啊。我用VC6.0编的。

成功会使人骄傲。如果你骄傲自大,你就会停止学习。不学习,人就停止了进步
2006-01-16 13:22
love_me
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2005-12-29
收藏
得分:0 

Visual C++ 概念:生成 C/C++ 程序

编译器错误 C2084函数“function”已有主体
函数已经定义。
在以前的 Visual C++ 版本中,
编译器将接受解析为同一实际类型的多个模板的专用化,尽管附加的定义将永远不可用。现在编译器将检测这些多重定义。
__int32 和 int 已被视为单独的类型。编译器现在将 __int32 作为 int 的同义词处理。这意味着,如果函数同时在 __int32 和 int 上重载,编译器将检测多个定义,并提供一个错误。
下面的示例生成 C2084:
// C2084.cpp
void Func(int);

void Func(int) // define specialization
{
}

void Func(int) // C2084 second definition
{
}


灌水无罪! 顶贴有理! <0_0>
2006-01-19 19:48
快速回复:D:\NO2\point.cpp(20) : error C2084: function 'double __thiscall P ...
数据加载中...
 
   



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

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