问题描述
- 新人求问:程序提示无法解析的外部符号,无法解析的外部命令
-
源代码如下
此处为头文件golf.h
//headfile golf
#ifndef golf
const int len=40;
struct golf
{
char fullname[len];
int handicap;
};
void setgolf(golf & g,char *name,int hc);
int setgolf(golf & g);
void handicap(golf & g,int hc);
void showgolf(const golf &g);
#endif函数的声明 fu.cpp
//declare the functions
#include
#include
#include"golf.h"
void setgolf(golf & g,const char *name,int hc)
{
name=g.fullname;
g.handicap=hc;
}
int setgolf(golf & g)
{
std::cin>>g.fullname;
std::cin>>g.handicap;
std::string c;
c=g.fullname;
if(c.empty())
return 0;
else
return 1;}
void handicap(golf & g,int hc)
{
g.handicap=hc;
}
void showgolf(const golf &g)
{
std::cout<
}
//主函数部分:gl.cpp
#include
#include"golf.h"
int main()
{
golf ann[2];
setgolf(ann[0],"dazhoang",14);
int go=setgolf(ann[1]);
handicap(ann[0],14);
std::cout<<go;
showgolf(ann[0]);
std::cout<<std::endl;
showgolf(ann[1]);
system("pause");
return 0;
}
解决方案
解决方案二:
哪个命令无法解析?
void showgolf(const golf &g)
{
std::cout< }
这是什么?没复制全?
解决方案三:
你所有定义的函数都有实现吗? 应该是找不到对应的实现。
解决方案四:
具体是哪个命令无法解析?
解决方案五:
你需要把cpp文件也要包含进去一起编译。
解决方案六:
无法解析的外部符号 这种错误就是函数只有声明没有定义,所以你找错方法就是看每个函数是否有定义