我收到以下错误:LNK2019错误与功能主要用于与Visual Studio 2012 C++
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;
}
}
};
,这里是interface.h
#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
好问的问题! –