C++;NetBeans错误:在';int'; 我是C++新手,我有错误,我不确定为什么有人能帮助我解决这个问题?提前谢谢

C++;NetBeans错误:在';int'; 我是C++新手,我有错误,我不确定为什么有人能帮助我解决这个问题?提前谢谢,c++,netbeans,C++,Netbeans,这是我的头文件 #ifndef SSTACK_H #define SSTACK_H #include <cstdlib> #include <string> class sstack { public: // Constructor sstack( int cap); // Copy Constructor sstack( const sstack& s )

这是我的头文件

#ifndef SSTACK_H
#define SSTACK_H

#include <cstdlib>
#include <string>

class sstack {
    public:
            // Constructor
            sstack( int cap);
            // Copy Constructor
            sstack( const sstack& s );
           ~sstack( );
            void push ( const std::string&  s);
            std::string& pop ();
            std::string&  top () const;
            bool IsEmpty () const;
            int size() const;
    int getCapacity() const;

    // NONMEMBER FUNCTIONS for the bag class
    // Precondition:  s1.size( ) + s2.size( ) <= s1.Capacity.
    // Postcondition: The stack returned is the union of s1 and s2.
    sstack operator +(const sstack& s2);

    private:
            int Capacity; // Capacity is the maximum number of items that a stack can hold
            std::string* DynamicStack; 
            int used; // How many items are stored in the stack
};

#endif
\ifndef SSTACK\H
#定义SSTACK_H
#包括
#包括
类策略{
公众:
//建造师
sstack(内部cap);
//复制构造函数
sstack(const-sstack&s);
~sstack();
无效推送(const std::string&s);
std::string&pop();
std::string和top()常量;
bool-IsEmpty()常量;
int size()常量;
int getCapacity()常量;
//bag类的非成员函数
//前提条件:s1.size()+s2.size()0;i--){
测试[i]=*s.pop();
}//结束
容量=s.getCapacity();
已使用=s.尺寸();
}
~sstack(){
删除[]测试;
}
无效推送(const std::string&s){
测试[使用]=*s;
使用++;
}
std::string&pop(){
使用-=1;
弹出=测试[使用];
测试[使用]=“”;
返回*弹出;
}
std::string和top()常量{
top=测试[使用--];
返回*顶部;
}
bool IsEmpty()常量{

如果(已使用)成员定义中缺少类范围:

sstack::sstack(int cap) { .... }
^^^^^^^^

void sstack::push ( const std::string&  s) { .... }
     ^^^^^^^^

您不应该在这里硬编码数组的大小
test=new std::string[1000]
。它不会是原件的真实副本。此外,更喜欢在构造函数初始值设定项列表中进行初始化。而且,实际上,远离“原始”数组。查看标准集合。谢谢。在此之后,我收到了一些错误sstack。cpp:67:29:error:“test”未在此范围内声明sstack。cpp:67:47:error:passing“const”sstack'作为'std::string&sstack::pop()'的'this'参数丢弃限定符[-fppermissive]sstack.cpp:67:47:错误:与'*(&s2)->sstack::pop()'中的'operator*'不匹配每次使用变量、测试和容量时,我几乎都会遇到这些错误
sstack::sstack(int cap) { .... }
^^^^^^^^

void sstack::push ( const std::string&  s) { .... }
     ^^^^^^^^