高手帮看看我编的程序有什么错误吗?

来源:百度知道 编辑:UC知道 时间:2024/05/21 21:50:55
*********
cpp01
*********
#include <iostream.h>
#include <stdlib.h>
#include "myhead.h"
int x=1;
int g();
void main()
{
x=g();
cout<<x<<endl;
system("pause");
}
*******
cpp02
*******
#include <iostream.h>
#include "myhead.h"
extern int x;
int func();
int g()
{
x=func();
return x;
}
*******
cpp03
*******
#include <iostream.h>
#include "myhead.h"
int func(int b=1)
{
return b;
}

*******
myhead.h
*********
int g(int a);
int func(int b);

制作EXE文件时它提示Linking...
CPP01.OBJ : error LNK2001: unresolved external symbol "int __cdecl g(void)" (?g@@YAHXZ)
Debug/习题.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
知道请详细解

建议你先把这些函数写到一个文件里编译一下,看能不能通过。

保证代码没错。 问题就在于文件的连接上了。

*************
这么说问题是,文件的连接了。

如 ,vqct43 - 见习魔法师 二级 所说。
int g() 是无参

myhead.h中 int g(int a); 改为 int g();