它顯示「鏈接器錯誤:致命錯誤LNK1120:1無法解析的外部」 整個項目=頭文件,第1個.cpp文件和第2個.cpp文件與main()函數。 Any1有想法什麼是做錯了嗎?鏈接器錯誤:致命錯誤LNK1120:1無法解析的外部鏈接
//golf.h for golf.cpp
const int Len = 40;
struct golf{
char fullname[Len];
int handicap;
};
//dla gotowych wartosci
void setgolf (golf & g, const char * name, int hc);
//do wpisywania wartosci
int setgolf (golf & g);
//tylko handicap
inline void handicap (golf & g, int hc);
//wyswietla info o graczu
void showgolf (const golf & g) ;
下一個文件
//golf.cpp for 9-1.cpp
#include <iostream>
#include <cstring>
#include "golf.h"
extern const int Len;
void setgolf (golf & g, const char* name, int hc){
strcpy(g.fullname,name);
g.handicap=hc;
}
int setgolf (golf & g){
using namespace std;
cout << "Podaj fullname golfiarza" << endl;
if (cin.getline(g.fullname,Len)) return 0;
cout << "Teraz podaj jego handicap" << endl;
cin >> g.handicap;
return 1;
}
inline void handicap (golf & g, int hc){
g.handicap=hc;
}
void showgolf (const golf & g){
using std::cout;
using std::endl;
cout << "Fullname gracza to: " << g.fullname << endl;
cout << "Jego handicap to: " << g.handicap << endl;
}
LAST FILE
#include <iostream>
#include <cstdlib>
#include "golf.h"
using namespace std;
int main(){
cout << "Witaj!\nTutaj program golficzny!" << endl;
golf filip;
golf klaudia;
cout << "Automatyczne uzupelnienie Filipa" << endl;
setgolf(filip, "Filip Bartuzi",100);
showgolf(filip);
cout << "Manualne uzupelnienie Klaudii" << endl;
((setgolf(klaudia))==1) ? showgolf(klaudia) : cout << "nie wprowadziles gracza!" << endl; ;
cout << "Zly handicap? Okey, zmienie handicap Filipowi" << endl;
handicap(filip,50);
showgolf(filip);
cout << "Od razu lepiej, nieprawda?" << endl;
system("PAUSE");
return 0;
}
任何想法?
錯誤的下一行是什麼? – 2013-02-15 21:09:00
1>生成代碼... 1> 9-1.obj:error LNK2019:無法解析的外部符號「void __cdecl handicap(struct golf&,int)」(?handicap @@ YAXAAUgolf @@ H @ Z)在函數中引用_main 1> C:\ Users \ Filip \ Dysk Google \ C++ \ Debug \ ConsoleApplication7.exe:致命錯誤LNK1120:1無法解析的外部設備 ========== Build:0成功,1次失敗,0次到目前爲止,0跳過========== – 2013-02-15 21:09:32