error LNK2001: unresolved external symbol "class std::basic_string,class std::allocator

NCF_BJ 2008-07-19 10:55:36
该程序是将中缀转为后缀形式,编译老出现标题上的错误,大家帮我看看啊
#include<iostream>
#include<string>
#include<cassert>
using namespace std;
#include<stack>
string RPN(string exp);
int main()
{
string exp;
cout<<"NOTE:enter# for infix expression\n";
for( ; ; )
{
cout<<"enter expression\n";
getline(cin,exp);
if(exp=="#")break;
cout<<"RPN expression is :"<<RPN(exp)<<endl;
}
return 0;
}
string RNP(string exp)
{
char token,
toptoken;
string RPNEXP;
stack<char> opstack;
const string BLANK=" ";
for(int i=0;i<exp.length();i++)
{
token=exp[i];
switch(token)
{
case' ':break;
case'(':opstack.push(token);
break;
case')':for( ; ; )
{
assert(!opstack.empty());
toptoken=opstack.top();
opstack.pop();
if(toptoken=='(')break;
RPNEXP.append(BLANK+toptoken);
}
break;
case'+':
case'-':
case'*':
case'/':for( ; ; )
{
if(opstack.empty()||opstack.top()=='('||(token=='*'||token=='/')
&&(opstack.top()=='-'||opstack.top()=='+'))
{opstack.push(token);
break;
}
else{
toptoken=opstack.top();
opstack.pop();
RPNEXP.append(BLANK+toptoken);
}
}
break;
default:RPNEXP.append(BLANK+token);
}
}
for( ; ; )
{
if(opstack.empty())break;
toptoken=opstack.top();
opstack.pop();
if(toptoken!='(')
{
RPNEXP.append(BLANK+toptoken);
}
else{
cout<<"*** Error in infix expression ***\n";
break;
}
}
return RPNEXP;
}


...全文
487 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hslinux 2008-07-25
  • 打赏
  • 举报
回复
string RPN(string exp);
string RNP(string exp)

函数声明与定义不一致。
NCF_BJ 2008-07-25
  • 打赏
  • 举报
回复

知道咯
谢谢哦
想死的心都有,这么简单
我就剩100多分了
moonwrong 2008-07-25
  • 打赏
  • 举报
回复
1,string RNP(string exp)//这里的RNP应该是RPN
{
char token,
toptoken;
2,<< ||之间没有空格

64,691

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧