1>main.obj : error LNK2019: unresolved external symbol "void __cdecl setup(void)" ([email protected]@YAXXZ) referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol "void __cdecl display(void)" ([email protected]@YAXXZ) referenced in function _main 1>C:\code\Project1\Debug\Project1.exe : fatal error LNK1120: 2 unresolved externals
내가이 문제를 어떻게 해결합니까? 여기
이 기능을 사용하는 메인 클래스입니다 : 여기#include "interface.h"
using namespace std;
int main(){
setup();
display();
system("pause");
return 0;
}
이 interface.cpp
#include <iostream>
#include <string>
#include "interface.h"
using namespace std;
class ui{
void setup(){
options[0][0]="Hello";
options[1][0]="Hello";
options[2][0]="Hello";
options[3][0]="Hello";
options[4][0]="Hello";
options[5][0]="Hello";
options[6][0]="Hello";
options[7][0]="Hello";
options[8][0]="Hello";
options[9][0]="Hello";
}
void changeOption(int whatOption, string whatText,
string prop1, string prop2, string prop3, string prop4, string prop5){
options[whatOption][0]=whatText;
options[whatOption][1]=prop1;
options[whatOption][2]=prop2;
options[whatOption][3]=prop3;
options[whatOption][4]=prop4;
options[whatOption][5]=prop5;
}
void display(){
for(int x=0;x<9;x++){
cout<<options[x][0]<<endl;
}
}
};
이며, 여기
#include <string>
//#include <iostream>
using namespace std;
#ifndef INTERFACE_H_INCLUDED
#define INTERFACE_H_INCLUDED
void setup();
extern string options[10][6];
void changeOption(int whatOption, string whatText, string prop1, string prop2, string prop3, string prop4, string prop5);
void display();
#endif INTERFACE_H
그것은 현재 상황에서 많은 도움이되지는 않지만 장기간 프로그래밍에서는 : inteface.h'에서 포함 가드 바깥에 아무것도 넣지 마십시오. – ch0kee
꽤 좋은 질문입니다! –