我已经在这个项目上工作了一段时间,并尝试过多种方法。请帮助我,我总是会遇到新的错误,这是最新的错误。
1>Main.obj : error LNK2019: unresolved external symbol "class miniStackVT<int> __cdecl myStack(void)" (?myStack@@YA?AV?$miniStackVT@H@@XZ) referenced in function "void __cdecl stackVector(void)" (?stackVector@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall miniStackVT<int>::~miniStackVT<int>(void)" (??1?$miniStackVT@H@@QAE@XZ) referenced in function "void __cdecl stackVector(void)" (?stackVector@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: int __thiscall miniStackVT<int>::size(void)const " (?size@?$miniStackVT@H@@QBEHXZ) referenced in function "void __cdecl stackVector(void)" (?stackVector@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall miniStackVT<int>::Push(int const &)" (?Push@?$miniStackVT@H@@QAEXABH@Z) referenced in function "void __cdecl stackVector(void)" (?stackVector@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall miniStackVT<int>::PrintStack(void)const " (?PrintStack@?$miniStackVT@H@@QBEXXZ) referenced in function "void __cdecl stackVector(void)" (?stackVector@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall miniStackVT<int>::Pop(void)" (?Pop@?$miniStackVT@H@@QAEXXZ) referenced in function "void __cdecl stackVector(void)" (?stackVector@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: int __thiscall miniStackVT<int>::TopStack(void)const " (?TopStack@?$miniStackVT@H@@QBEHXZ) referenced in function "void __cdecl stackVector(void)" (?stackVector@@YAXXZ)
这是我的主文件main.cpp
#include <iostream>
#include <string>
#include "miniStack.h"
//#include "miniQueue.h"
using namespace std;
void Menu();
void stackVector();
int main()
{
Menu();
return 0;
}
void Menu()
{
int num = 0;
do{
cout << "Will you be using: " << endl;
cout << "1 Stack" << endl;
cout << "2 Queue" << endl;
cin >> num;
} while (num != 1 && num != 2);
if (num == 1)
{
do {
cout << "Will you be using: " << endl;
cout << "1 vector" << endl;
cout << "2 list" << endl;
cout << "3 dynamic array" << endl;
cin >> num;
} while (num != 1 && num != 2 && num != 3);
if (num == 1) // Stack vector
{
stackVector();
}
else if (num == 2) // Stack list
{
//stackList();
}
else if (num == 3) // Stack dynamic array
{
//stackArray();
}
}
else if (num == 2)
{
do{
cout << "Will you be using: " << endl;
cout << "1 vector" << endl;
cout << "2 list" << endl;
cout << "3 dynamic array" << endl;
cin >> num;
} while (num != 1 && num != 2 && num != 3);
if (num == 1) // Queue vector
{
//queueVector();
}
else if (num == 2) // Queue list
{
//queueList();
}
else if (num == 3) // Queue dynamic array
{
//queueArray();
}
}
}
void stackVector()
{
int num;
int item;
miniStackVT<int> myStack();
cout << "Please choose from the following menu: " << endl;
cout << "1 Add an element" << endl;
cout << "2 Remove an element" << endl;
cout << "3 display the contents" << endl;
cout << "4 display the size" << endl;
cout << "5 display the first element" << endl;
cin >> num;
if (num == 1)
{
cout << "What you like to add into the stack?" << endl;
cin >> item;
myStack().Push(item);
}
else if (num == 2)
{
myStack().Pop();
}
else if (num == 3)
{
myStack().PrintStack();
}
else if (num == 4)
{
cout << myStack().size();
}
else if (num == 5)
{
cout << myStack().TopStack();
}
}