c语言参数未定义,变量未定义?明明定义了啊、、、

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

请各位高手看下这代码怎么有问题了,明明申明了变量怎么VC6.0上老是提示"undeclared identifier"

const int maxstack=20;//stack.h

typedef int Stack_entry;

enum Error_code{success,underflow,overflow};

class Stack

{

public:

Stack();

Error_code push(const Stack_entry &item);

Error_code pop();

Error_code top(Stack_entry &item)const;

bool empty()const;

protected:

int count;

Stack_entry entry[maxstack];

};

class Extended_stack:public Stack

{

public:

bool full()const;

int size()const;

void print();

void clear();

Error_code stack_copy(Extended_stack &source);

};

#include"stack.h"//stack.cpp

Stack::Stack()

{

count=0;

}

bool Stack::empty()const

{

return(count==0);

}

bool Extended_stack::full()const

{

return(count==maxstack);

}

Error_code Stack::push(const Stack_entry &item)

{

if(count>=maxstack)

return overflow;

entry[count]=item;

count++;

return success;

}

Error_code Stack::pop()

{

if(count<=0)

return underflow;

count--;

return success;

}

Error_code Stack::top(Stack_entry &item)const

{

if(count<=0)

return underflow;

item=entry[count-1];

return success;

}

int Extended_stack::size()

{

return count;

}

void Extended_stack::print()

{

if(count==0)

cout<

else

{

int i;

cout<

for(i=count-1;i>=0;i--)

cout<

}

}

void Extended_stack::clear()

{

count=0;

}

Error_code Extended_stack::stack_copy(Extended_stack &source)

{

if((maxstack-count)<=source.count)

return overflow;

else

{

int i,t;

desk.count=source.count;

for(i=count-1,t=0;i

{

entry[i]=source.entry[t];

count++;

}

}

return success;

}

typedef int Stack_entry;//test.cpp

#include"iostream"

using namespace std;

#include"stack.h"

int main()

{

void introduction();

char get_command();

bool do_command(char c,Stack &test_stack);

Extended_stack test;

Extended_stack test_stack;

introduction();

while(do_command(get_command(),test_stack));

return 0;

}

void introduction()

{

cout<

<

<

<

<

<

<

<

<

<

<

}

char get_command()

{

char c;

cout<

cin>>c;

return c;

}

bool do_command(char c,Extended_stack &test_stack)

{

bool continue_input=true;

Stack_entry x;

if(c>=65&&c<=90)c=c+32;

switch(c)

{

case 'i':

if(test_stack.full())

cout<

else

{

cout<

cin>>x;

test_stack.push(x);

}

break;

case 's':

if(test_stack.top(x)==underflow)

cout<

else

cout<

break;

case 'd':

if(test_stack.pop()==underflow)

cout<

else

cout<

break;

case 'p':

cout<

test_stack.print();

break;

case '#':

cout<

break;

case 'r':

test_stack.clear();

cout<

break;

case 'c':

test.stack_copy(test_stack);

cout<

test.print();

break;

case 'q':

continue_input=false;

break;

}

return continue_input;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值