| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 820 人关注过本帖
标题:这个程序为什么有这些错误啊???
取消只看楼主 加入收藏
zclllt
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2006-3-16
收藏
 问题点数:0 回复次数:0 
这个程序为什么有这些错误啊???

#include"a.h"
#include <iostream>
#include <cmath>
#include<cstdlib>
#include <cstring>
#include <assert.h>
#include "stack.h"
using namespace
enum Boolean[False,Ture];
template<class Type>class Stack{
public:
Stack (int=10);
~Stack(){delete[]elements;}
void Push(const Type&item);
Type Pop();
Type GetTop();
void MakeEmpty(){top=-1;}
int IsEmpty()const{return top==-1;}
int IsFull()const{return top==maxSize-1};
private:
int top;
Type *elements;
int maxSize;
};
template<class Type> Stack<Type>::Stack(int s):top(-1),maxSize(s){
elements=new Type[maxSize];
assert(elements!=0);
}
template<class Type>void Stack<Type>::Push(const Type&item){
assert(!IsFull());
elements[++top]=item;
}
template<class Type>Type Stack<Type>::Pop(){
assert(!IsEmpty());
return elements[top--];
}
template<class Type>Type Stack<Type>::GetTop(){
assert(!Is Empty());
return elements[top];
}
class Calculator{
public:
Calculator(int sz):s(sz){}
void Run();
void Clear();
private:
void AddOperand(double value);
enum Boolean ;GetTwoOperands(double&left,double&right)
void DoOperand(char op);
class stack;

};
void Calculator::AddOperand(double value){
void Push(const value);
}
Boolean Calculator::GetTwoOPerands{double&left,double&right};
{
if (s.IsEmpty())
{
cerr<<"Missing Operand!"<<endl; return False;
}
right=s.Pop();
if(s.IsEmpty()){
cerr<<"Missing Operand!"<<endl; return False;
}
left=s.Pop();
return Ture;
}
void Calculator::DoOperator(char op){
double left,right; Boolean result;
result=Get2Operands(left,right);
if(result==Ture)
switch(op){
case'+': s.Push(left+right);break;
case'-': s.Push(left-right);break;
case'*': s.Push(left*right);break;
case'/': if(right==0.0){
cerr<<"Divide by 0!"<<endl; Clear();
}
elses.Push(result=left/right);break;
case'^': s.Push(Power(left,right));break;
}
else Clear();
}
void Calculator::Run(){
char c[20];
while(cin>>d,*c!='q')
switch(*c)
{
case'c': S.ClearStack();
break;
case'-'
if(strlen(c)>1)
AddOperand(atoi));
else DoOperator (*c);
break;
case'+':
case'*':
case'/':
case'^':
Do Operator(*c);
break;
default:
AddOperand(atoi(c));
break;
}
}
void Calculator::Clear(void)
{S.ClearStack();}
//1.cpp

int main()
{
Calculator CALC;
CALC.Run();
}

ompiling...
1.cpp
L:\051170114\1\1.cpp(9) : error C2226: syntax error : unexpected type 'Boolean'
L:\051170114\1\1.cpp(49) : warning C4518: 'void ' : storage-class or type specifier(s) unexpected here; ignored
L:\051170114\1\1.cpp(49) : error C2146: syntax error : missing ';' before identifier 'DoOperand'
L:\051170114\1\1.cpp(56) : error C2039: 'GetTwoOPerands' : is not a member of 'Calculator'
L:\051170114\1\1.cpp(41) : see declaration of 'Calculator'
L:\051170114\1\1.cpp(56) : error C2146: syntax error : missing ';' before identifier 'GetTwoOPerands'
L:\051170114\1\1.cpp(56) : error C2501: 'Boolean' : missing storage-class or type specifiers
L:\051170114\1\1.cpp(56) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

1.obj - 6 error(s), 1 warning(s)


搜索更多相关主题的帖子: include const Type void 
2006-12-26 23:03
快速回复:这个程序为什么有这些错误啊???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.064777 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved