我正在尝试运行一个程序,但它不会编译,我得到错误。我已经改变了一些东西,但似乎没有用。代码是这样的:
#include <iostream>
#include <string>
#include "StackLS.h"
using namespace std;
int main()
{
int answer;
char symbol;
char n, N;
StackLS stack;
bool balenced = true;
do {
cout << " ********** MENU ********** " << endl;
cout << " 1. Basic Brackets () " << endl;
cout << " 2. Standard Brackets ()[]{} " << endl;
cout << " 3. User-Defined brackets " << endl;
cout << " Please enter your choice: " << endl;
switch (answer){
case 1:
cout << "Current Setting: () " << endl;
cout << "Enter your expression followed by a ; : " << endl;
cin >> symbol;
do {
if (symbol = '(')
stack.push( '(' );
else
if (symbol = ')' )
{
if (stack.isEmpty())
balenced = false;
else {
symbol = stack.top();
stack.pop();
}
if (balenced)
cout << "Expression is well-formed" << endl;
else
cout << "Expression is not well-formed" << endl;
}
}
while (symbol != ';' && balenced);
stack.pop();
}
}
while (answer != 'n' || 'N');
} // end main
我还没有完成程序。在继续下一个案例之前,我想确保我到目前为止所拥有的内容能够编译。现在我将发布我遇到的错误。他们是:
1>e:\c++ language 2\well-formed expression checker solution\well-formed expression checker project\main.cpp(11): warning C4101: 'n' : unreferenced local variable
1>e:\c++ language 2\well-formed expression checker solution\well-formed expression checker project\main.cpp(11): warning C4101: 'N' : unreferenced local variable
1>e:\c++ language 2\well-formed expression checker solution\well-formed expression checker project\main.cpp(22): warning C4700: uninitialized local variable 'answer' used
1>ManifestResourceCompile: 1> 所有输出都是最新的。
1>main.obj : 错误 LNK2019: 函数 _main 中引用的未解析外部符号“public: int __thiscall StackLS::top(void)const” (?top@StackLS@@QBEHXZ)
1>main.obj:错误 LNK2019:函数 _main 中引用的未解析外部符号“public:void __thiscall StackLS::push(int const &)”(?push@StackLS@@QAEXABH@Z)
1>E:\C++ language 2\Well-Formed Expression Checker Solution\Debug\Well-Formed Expression Checker Project.exe : 致命错误 LNK1120: 2 unresolved externals
谢谢您的帮助。