程序和函数定义要分开,可是找不到这是为什么啊
在做例题,不知道错哪里,大侠来瞧瞧...............第2个程序调用第1个时候就出错了说没有'MyFunction.h':没有那个文件或目录...我都保存了的。。。是不是保存的地址错了?应该保存在那个地址啊??
1.
#include "MyFunction.h"
int GetTotal(int XX,int SX,int KD)
{
int total=0;
for(int i=XX;i<=SX;i+=KD;)
{
total+=i;
}
return total;
}
2.
#include<iostream>
#include"MyFunction.h"
using namespace std;
int main()
{
int XX;
int SX;
int KD;
cout<<"输入运算下限:"<<endl;
cin>>XX;
cout<<"输入运算上限:"<<endl;
cin>>SX;
cout<<"输入累加跨度:"<<endl;
cin>>KD;
cout<<"累加和为:"<<GetTotal(XX,SX,KD)<<endl;
cin.get();
return 0;
}
错误报告
Compiling...
main.cpp
e:\c++\msdev98\myprojects\gfh\main.cpp(2) : fatal error C1083: Cannot open include file: 'MyFunction.h': No such file or directory
MyFunction.cpp
e:\c++\msdev98\myprojects\gfh\myfunction.cpp(1) : fatal error C1083: Cannot open include file: 'MyFunction.h': No such file or directory
执行 cl.exe 时出错.
gfh.exe - 1 error(s), 0 warning(s)