编译包含vector头文件时候出错!

grUngeJX grUngeJX 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
源程序:
#include<vector>

class iStack {
public:
iStack(){_top = 0;}
iStack( int capacity )
: _stack( capacity ), _top( 0 ) { }
void pop( int &top_value );
void push( int value );
bool full();
bool empty();
void display();
int size();
private:
int _top;
std::vector<int> _stack;
};

#include <iostream>
#include "iStackExcep.h"
#include "istack.h"
using std::cout;
using std::endl;
void iStack::pop( int &top_value )
{
if ( empty() )
throw popOnEmpty();
top_value = _stack[ --_top ];
cout << "iStack::pop(): " << top_value << endl;
}
void iStack::push( int value )
{
cout << "iStack::push( " << value << " )\n";
if ( full() )
throw pushOnFull();
_stack[ _top++ ] = value;
}

bool iStack::full()
{
return _stack.size()==_stack.capacity()? true:false;
}

bool iStack::empty()
{
return _stack.empty();
}

int size()
{
return _stack.size();
}

void display()
{
cout << "(" ;
for( int ix = 0, ix < _stack.size(), ++ix )
cout << _stack[ix] << ",";
cout << "\b)" << endl;
}

g++显示
in file include from /usr/include/c++/4.2/vector:70
from istack.h 1,
from istack.cc 3:
/usr/include/c++/4.2/bits/stl_vector.h expected unqualified-id befor 'namespace'

这个是怎么回事?
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
grUngeJX
C++ 语言 65,214 成员 250,514 内容