企业里的职位有哪些:c++初学者的问题,求高手们帮忙!

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/03 05:42:06
我是自学C++的,所以,如果觉得问题很幼稚不要笑话我哦.
在运行外部函数的定义,说明和调用时,有f1.cpp
f2.cpp ,f3.cpp三个文件.其中f1.cpp中是主调函数,f2.cpp ,f3.cpp里是被定义成的外部函数.
当我编译f1.cpp时无错,可当我运行它时却提示:
Cpp1.obj : error LNK2001: unresolved external symbol "int __cdecl other(int)" (?other@@YAHH@Z)
Cpp1.obj : error LNK2001: unresolved external symbol "int __cdecl last(void)" (?last@@YAHXZ)
Cpp1.obj : error LNK2001: unresolved external symbol "int __cdecl next(void)" (?next@@YAHXZ)
Cpp1.obj : error LNK2001: unresolved external symbol "int __cdecl reset(void)" (?reset@@YAHXZ)
Debug/Cpp1.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.

Cpp1.exe - 5 error(s), 0 warning(s)
这是为什么啊?

下面是代码:
f1.cpp:#include<iostream.h>
int i(1);
extern int reset(),next(),last(),other(int);
void main()
{
int i=reset();
for (int j(i);j<=3;j++)
{
cout<<i<<","<<j<<",";
cout<<next()<<",";
cout<<last()<<",";
cout<<other(i+j)<<endl;

}
}
f2.cpp:static int i(10);
extern int next()
{
return i+=1;

}
extern int last()
{
return i-=1;
}
extern int other(ubt i)
{
static int j(5);
return i=j+=1;
}
f3.cpp:extern int j;
extern int reset()
{
return i;
}

请问你定义的外部函数:int reset();int next();
int last();int other(int);是从哪里来的。怎么不见你把它所要的文件包含进来。
f2.cpp和f3.cpp都是你定义的外部函数,你要用到里面的子函数,怎么不见你使用包含语句:
#include f2.cpp
#indlude f3.cpp
类似的语句,编译器当然找不到上述的外部函数了。

天啊?这么多!你还初学吗?