C++ 将2D数组传递到函数中
我想将类Menza的2D数组传递到函数中C++ 将2D数组传递到函数中,c++,arrays,C++,Arrays,我想将类Menza的2D数组传递到函数中 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 Pr
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
有人能解释一下这个函数调用有什么问题吗
谢谢您没有
LoadFile
函数的定义,只有声明。因此,编译器无法理解这个函数应该做什么。
您必须定义它或链接定义它的库(并包括此库的标题)。(对于客户选择
也是如此)
阅读更多关于定义和声明之间差异的信息:在声明:const int-nunches=5下,
LoadFile
的定义在哪里;这是一份声明。定义在哪里?void InputFile(bool FileChoice,Menza(*InputFromFile)[午餐]{//some stuff}这是在Semestralka.exe中链接的吗?在这两种情况下,“午餐”的价值相同吗?如果您的问题是通过移动定义解决的,因此它位于main
的正上方,那么其中一个问题的答案可能是“否”。这里有我的完整代码(尚未完成),还有我的方法的声明和定义。。谢谢你的帮助help@user3072249,请说得更具体些。您在哪里有LoadFile(…)的定义?我在那里看不到。