注册 登录
编程论坛 C++教室

【求助】缺少函数头什么意思

TND 发布于 2009-09-13 12:53, 2345 次点击
#include<iostream>
#define SIZE 10
using namespace std;
class CStack
{
    private:
        int position;
        char stk[SIZE];
    public:
        void init(){position=0;}
        char push(char ch);
        char pop();
};
char CStack::push(char ch)
{
    if (position==SIZE)
    {
        cout<<" stack is full"<<endl;
        return 0;
    }
    stk[position++]=ch;
    return ch;
};
char CStack::pop();
{
    if(position==0)
    {
        cout<<"stack is null"<<endl;
        return 0;
    }
    return str[position--];
};
int main()
{
    CStack s;
    s.init();
    char ch;
    while(ch!='!'&&s.push(ch))
        cin>>ch;
    while(ch=s.pop())
        cout<<ch;
    return 0;
}

编译时,出现missing function header (old-style formal list?)  是怎么回事???
5 回复
#2
debroa7232009-09-13 23:29
int _tmain(int argc,_TCHAR* argv[]){
    ......
    return 0; }
#3
shl3052009-09-13 23:56
回复 楼主 TND
#include<iostream>
#define SIZE 10
using namespace std;
class CStack
{
    private:
        int position;
        char stk[SIZE];
    public:
        void init(){position=0;}
        char push(char ch);
        char pop();
};
char CStack::push(char ch)
{
    if (position==SIZE)
    {
        cout<<" stack is full"<<endl;
        return 0;
    }
    stk[position++]=ch;
    return ch;
};
char CStack::pop();
{
    if(position==0)
    {
        cout<<"stack is null"<<endl;
        return 0;
    }
    return str[position--];
};
int main()
{
    CStack s;
    s.init();
    char ch;
    while(ch!='!'&&s.push(ch))
        cin>>ch;
    while(ch=s.pop())
        cout<<ch;
    return 0;
}

红色部分改过后就对了,我用gcc编译的
#4
TND2009-09-14 09:16
回复3楼
貌似没改啊!
#5
flyingcloude2009-09-14 09:40
回复 4楼 TND
第一个红色部分多了一个分号,第二个红色部分的你用了str,而你在类中定义的是stk


[ 本帖最后由 flyingcloude 于 2009-9-14 09:42 编辑 ]
#6
TND2009-09-16 20:57
哦,晓得了!谢谢

1