各位大佬!!求求了,这个程序是怎么分析的,结果怎么看的。
#include<iostream>
using namespace std;
#define N 100
class Cstack
{ public:
Cstack ( ) {top=0; cout<<"hello!"; }
~Cstack ( ) { cout<<"bye"; }
void push( int i );
int pop( );
private:
int stack[N];
int top;
};
void Cstack::push (int i )
{ if(top==N ) { cout<<"overflow"; return ; }
else { top++ ; stack[top]=i ; }
}
int Cstack::pop( )
{ int temp;
if(top==0){ cout<<"underflow"; return 0; }
else { temp=stack[top]; top--; return temp ; }
}
int main( )
{ Cstack *ptr=new Cstack;
ptr->push(10);
ptr->push(50);
cout<<ptr->pop( )<< " ";
cout<<"OK!"<<endl;
}
这是从哪复制粘贴的代码,一些引号,括号都是中文的
还有==之间还有空格
1、37行:括号是中文的
2、53行:引号是中文的
3、27行、37行,==之间有空格