错误LNK2019:函数_main visual c++中引用了未解析的外部符号
error LNK2019: unresolved external symbol referenced in function _main visual c++
有人知道如何解决这个问题吗?我已经在线查看并更改了visual C++的设置,但它仍然不起作用。
class store
{
public:
int MainMenu();
store();
private:
int main;
};
class customer:store
{
public:
int CustomerMenu();
customer();
private:
int cmenu;
};
class employee:store
{
public:
int EmployeeMenu();
employee();
private:
int emenu;
};
int main()
{
int main;
store a;
customer b;
employee c;
a.MainMenu();
if(main = 1)
{
c.EmployeeMenu();
}
else if(main = 2)
{
b.CustomerMenu();
}
else
{
exit(EXIT_SUCCESS);
}
}
int MainMenu()
{
int main;
cout << "Choose an option: " << endl;
cout << " 1. Administration menu" << endl;
cout << " 2. Customer menu" << endl;
cout << " 3. Exit the program" << endl;
cin >> main;
return main;
}
int CustomerMenu()
{
int cmenu;
cout << " 1. Search Video" << endl;
cout << " 2. View Video Titles" << endl;
cout << " 3. Rent Video" << endl;
cout << " 4. Exit to the Main Menu" << endl;
cout << " 5. Exit the program" << endl;
cin >> cmenu;
return cmenu;
}
int EmployeeMenu()
{
int emenu;
cout << " 1. Store Information menu" << endl;
cout << " 2. Merchandise Information menu" << endl;
cout << " 3. Category Information menu" << endl;
cout << " 4. Customer Information menu" << endl;
cout << " 5. Employee Information menu" << endl;
cout << " 6. Rent a Video" << endl;
cout << " 7. Restock Video" << endl;
cout << " 8. Sales menu" << endl;
cout << " 9. Exit to Main Menu" << endl;
cout << " 10. Exit the program" << endl;
cin >> emenu;
return emenu;
}
store::store()
{
main = 0;
}
customer::customer()
{
cmenu = 0;
}
employee::employee()
{
emenu = 0;
}
它给了我:
Store.obj : error LNK2019: unresolved external symbol "public: int __thiscall customer::CustomerMenu(void)" (?CustomerMenu@customer@@QAEHXZ) referenced in function _main
1>Store.obj : error LNK2019: unresolved external symbol "public: int __thiscall employee::EmployeeMenu(void)" (?EmployeeMenu@employee@@QAEHXZ) referenced in function _main
1>Store.obj : error LNK2019: unresolved external symbol "public: int __thiscall store::MainMenu(void)" (?MainMenu@store@@QAEHXZ) referenced in function _main
您将CustomerMenu()
和EmployeeMenu()
实现为普通函数,而不是类成员。实施应:;
int customer::CustomerMenu()
{
...
int employee::EmployeeMenu()
{
...
您的成员函数实现需要正确定义。例如:
int CustomerMenu()
应为:
int customer::CustomerMenu(void)
等等。
if(main = 1)
{ //^^should be ==, same as the one below
c.EmployeeMenu();
}
else if(main = 2)
{
b.CustomerMenu();
}
应使用范围解析运算符定义成员功能:
int CustomerMenu()
应该是:
int Customer::ustomerMenu()
次要点:
class employee:store
在这里,您使用了private inheritance
,您真的需要考虑是否需要它。
相关文章:
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- 未解析的外部符号_MsiLocateComponentW@12.
- 在C++中使用 gRPC 时未解析的外部符号
- LibPrivoxy: 未解析的外部符号 __declspec(dllimport) int __stdcall Sta
- 尝试从 XamlApplication 编译 C++/WinRT 空白应用程序时,我收到未解析的外部符号 winrt_make_*
- 我收到错误LNK2001:未解析的外部符号(C++代码)
- 可视抽象类 c++(错误 LNK 2001:未解析的外部符号)
- 如何摆脱C++中未解析的外部符号"private: static char"错误?
- 当 lib 已添加到其他依赖项时,如何在 VS 中调试未解析的外部符号错误
- 仅在少数方法(静态或共享库)中解析的外部符号
- 未解析的外部符号"__declspec(dllimport)与 Spdlog c++ 库
- 函数 _main (OPENGL C++) 中引用的未解析的外部符号 ________
- 错误LNK2019未解析的外部符号"public: __thiscall SLinkList<char>::SLinkList<char>(void)"
- 使用静态 constexpr 成员的未解析外部符号
- 引入参数化构造函数后显示 LNK 2019 未解析外部符号的代码错误
- Dlib LNK2001未解析的外部符号USER_ERROR__consistent_build_configurati
- 矛盾的未解决的外部符号+未使用的库与VS2017和FFMPEG 4
- 链接器错误:切换到unicode生成给出:未解析的外部符号WinMain
- 错误 LNK2019:未解析的外部符号"外部"C"此错误是什么?
- 错误 : LNK2019: 未解析的外部符号"外部 "C"