这是half.h 文件
class student1
{
public:
float i;
public :
float shalf(float i);
};
student1::shalf(float i)
{
i=i*0.5;
return i;
}
下面是.cpp文件
#include "iostream.h"
#include
#include "StdAfx.h"
#include
void main()
{
student1 s1;
float h=100;
float i;
i=s1.shalf(h);
count<<i<<endl;
}
编译时出错E:\c++\102\102.cpp(11) : error C2065: 'student1' : undeclared identifier
你贴的代码对吗?
main函数是在cpp文件中的?
student1::shalf(float i)
{
i=i*0.5;
return i;
}
这个函数也有问题啊,student1前面没有申明返回值类型
是的 我是新建的工程文件,编译时一直提示2065错误
你好 我可以加一下你的qq么? 能把图片发给你,您能帮我看一下 非常感谢您
.h没有include