| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 944 人关注过本帖
标题:这个程序编译出现1个错误,错在哪里了?
只看楼主 加入收藏
hddgwxn586
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2017-5-18
结帖率:66.67%
收藏
 问题点数:0 回复次数:2 
这个程序编译出现1个错误,错在哪里了?
请教  下面这个程序编译出现1个错误,错在哪里了?c:\c++800\circle4.cpp(21) : error C2059: syntax error : ')'


#include <iostream.h>
class CCircle
{
  public:
   CCircle(int r);
void Set(int r);
void Set(int r,int c);
int Get(void);
void DisplayArea(void);
~CCircle();
int m_Color;
private:
float CalculateArea(void);
int m_R;
 
};

CCircle::CCircle(int r)
{
  m_R=r;
  m_Color=();
}

CCircle::~CCircle()
{
}

void CCircle::DisplayArea(void)
{
 float fArea;
fArea=CalculateArea();
cout<<"The area of the circle is:"<<fArea<<endl;

}

float CCircle::CalculateArea(void)
{
float f;
f=3.14*m_R*m_R;
return f;

}

void CCircle::Set(int r)
{
m_R=r;
m_Color=255;
}

void CCircle::Set(int r,int c)
{
m_R=r;
m_Color=c;
}

 CCircle::Get(void) //
{
return m_R;
}

void main()
{
CCircle Mycircle(10);
cout<<"The m_R is:\n"<<Mycircle.Get()<<"\n";
cout<<"The m_Color is:\n"<<Mycircle.m_Color;
cout<<"\n";
 
Mycircle.Set(20);
cout<<"The m_R is:\n"<<Mycircle.Get()<<"\n";
cout<<"The m_Color is:\n"<<Mycircle.m_Color;
cout<<"\n";
Mycircle.Set(40,100);
cout<<"The m_R is:\n"<<Mycircle.Get()<<"\n";
cout<<"The m_Color is:\n"<<Mycircle.m_Color;
cout<<"\n";
  
}
Compiling...
circle4.cpp
c:\c++800\circle4.cpp(21) : error C2059: syntax error : ')'
c:\c++800\circle4.cpp(39) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
Error executing cl.exe.

circle4.obj - 1 error(s), 1 warning(s)

搜索更多相关主题的帖子: int void Set cout The 
2017-07-14 10:19
ldsh304
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:7
帖 子:242
专家分:755
注 册:2016-1-18
收藏
得分:0 
m_Color=();//这是什么鬼
f=3.14*m_R*m_R;//把double类型转换成float类型,会丢失精度

[此贴子已经被作者于2017-7-14 10:28编辑过]

2017-07-14 10:26
hddgwxn586
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2017-5-18
收藏
得分:0 
回复 2楼 ldsh304
谢谢你。问题解决。
2017-07-14 11:05
快速回复:这个程序编译出现1个错误,错在哪里了?
数据加载中...
 
   



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

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