编译包含vector头文件时候出错!
源程序:
#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'
这个是怎么回事?