VC++错误帮我呀哥哥门不然我要自杀

来源:百度知道 编辑:UC知道 时间:2024/06/28 00:12:29
#include "iostream.h"
main()
{
int y;
int set(int a,int d){

int z;
z=(a*d-1);
return;
}

const pi=3.14;
cout<<y=set(200,100);
}

C:\Documents and Settings\linux\桌面\d.cpp(5) : error C2601: 'set' : local function definitions are illegal
C:\Documents and Settings\linux\桌面\d.cpp(13) : warning C4244: 'initializing' : conversion from 'const double' to 'const int', possible loss of data
C:\Documents and Settings\linux\桌面\d.cpp(14) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
C:\Documents and Settings\linux\桌面\d.cpp(15) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.

d.exe - 1 error(s), 0 warning(s)

#include <iostream>
using namespace std;
double set(float a,float d)
{
double z;
z=(a*d-1);
return z;
}
main()
{
double y;

const float pi=3.14;
y=set(200,100);
cout<<y<<endl;
}

int set(int a,int d){

int z;
z=(a*d-1);
return;
}
这个函数定义和实现是不能放在主函数中的,你可以把它提到主函数的前面。还有return z;这样才对,不然没有返回值。