我想将我的二维阵列Menza传递给函数..
class Menza
{
public:
string PrintLunch() const {return Lunch;};
unsigned int PrintID() const {return ID;};
double PrintPrice() const {return Price;};
double PrinteValue() const {return eValue;};
string PrintDescription() const {return Description;};
void ChangeLunch(string Change) {Lunch = Change;};
void ChangePrice(double Change) {Price = Change;};
void ChangeID(int Change) {ID = Change;};
void ChangeeValue(double Change) {eValue = Change;};
void ChangeDescription(string Change) {Description = Change;};
private:
string Lunch;
double Price;
unsigned int ID;
string Description;
double eValue;
};
const int Lunches = 5;
void LoadFile(bool FileChoice,Menza (*InputFromFile)[Lunches]);
void CustomerSelection(Menza CustomerSelect[],Menza (*InputFromFile)[Lunches]);
int main()
{
Menza InputFromFile[Lunches][Lunches];
Menza CustomerSelect[Lunches];
bool FileChoice = false;
LoadFile(FileChoice,InputFromFile);
CustomerSelection(CustomerSelect,InputFromFile);
}
编译完成后,它会显示我:
Semestralka.obj : error LNK2019: unresolved external symbol "void __cdecl LoadFile(bool,class Menza (*)[5])" (?LoadFile@@YAX_NPAY04VMenza@@@Z) referenced in function _main
1>E:\My VSB\ZP projekty\Semestralka\Debug\Semestralka.exe : fatal error LNK1120: 1 unresolved externals
有人可以解释一下这个函数调用中的错误吗?
谢谢
答案 0 :(得分:0)
您没有LoadFile
函数的定义,只有声明。因此编译器无法理解此函数应该做什么。
您必须定义它或链接定义它的库(并包含此库中的标头)。 (同样适用于CustomerSelection
)。
在此处阅读有关定义和声明之间差异的更多信息:declare_vs_define