プログラムを実行しようとしていますが、コンパイルされないため、エラーが発生します。私はものを変えましたが、うまくいかないようです。コードは次のとおりです。「エラーLNK2019:未解決の外部シンボル」とは何ですか?
#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++言語2 \整形式チェッカー溶液\整形式チェッカープロジェクトの\ main.cppに(11):C4101警告: 'N':参照されていないローカル変数
1> E:\ C++言語2 \整形式チェッカー溶液\整形式チェッカープロジェクトの\ main.cppに(11):C4101警告: 'N':参照されていないローカル変数
1> e:\ C++言語2 \ well-formed式チェッカーソリューション\ well-formed式チェッカープロジェクト\ main.cpp(22):警告C4700:未初期化ローカル変数 'answer'が使用されました
1> ManifestResourceCompile: 1>すべての出力は最新です。
1> MAIN.OBJ:エラーLNK2019:未解決の外部シンボル "パブリック:int型__thiscall StackLS ::トップ(無効)constは"(?StackLS @@ QBEHXZ @トップ)_main関数内で参照さ
1> MAIN.OBJ:エラーLNK2019:未解決の外部シンボル "パブリック:無効__thiscallのStackLS ::プッシュ(int型のconst &)"
1> _main機能で参照(@ StackLS @@ QAEXABH @ Zを押して?) E:\ C++言語2 \ Well-Formed Expression Checker Solution \ Debug \ Well-Formed Expression Checker Project.exe:致命的なエラーLNK1120:2未解決のexternその他
ありがとうございました。
私は1) 'n'は参照されていない(未使用の)ローカル変数で、2)' N'は参照されていないローカル変数で、3) 'answer'はそれ以前に使われていると思います。初期化されました。私は未使用の地元の人々を取り除き、初心者のために '答え'を初期化することをお勧めします。 –
これは警告です。エラーはリンカから来ています。 StackLSライブラリを正しくリンクしていないようです。 – tmpearce
Lea - あなたのメイクファイルもここに貼り付けてください。 –