C++高手,菜鸟发问~~

来源:百度知道 编辑:UC知道 时间:2024/05/11 18:44:32
#include<iostream.h>
#define pi 3.1415926;
double Area(double r)
{

return pi*r*r;
}
void main()
{
double radius,area;
cout<<endl<<"请输入圆的半径=";
cin>>radius;
area=Area(radius);
cout<<endl<<"面积="<<area;
}
在VC++下编译老是有错,是在不知道是那里错了请高手指教
报错:
Compiling...
area.cpp
E:\Microsoft Visual Studio\MyProjects\yiyivctest\area.cpp(6) : error C2100: illegal indirection
E:\Microsoft Visual Studio\MyProjects\yiyivctest\area.cpp(6) : warning C4552: '*' : operator has no effect; expected operator with side-effect
Error executing cl.exe.

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

#define pi 3.1415926;中的分号去掉就OK了。

宏定义多了分号

不错

#define pi 这一行后面不要 “ ;”
在 主函数里 没有 Area函数 的申明,应加上 double Area(double);
主函数 最后少了 return 0;

楼上
void main()
{
}需要写return 0;
????????????????????????????????