VS2005下编译 essential第四章中例子遇到的问题
Stack.h文件中如下
#pragma once
class Stack
{
public:
bool push( const string& );
bool pop( string &elem );
bool peek( string &elem );
bool empty();
bool full();
int size() { return _stack.size(); }
Stack(void);
public:
~Stack(void);
private:
vector<string> _stack;
};
void fill_stack( Stack &stack, istream &is = cin )
{
string str;
while ( is >> str && ! stack.full() )
stack.push( str );
cout << "Read in " << stack.size() << " elements\n";
}
inline bool
Stack::empty()
{
return _stack.empty();
}
bool
Stack::pop( string &elem )
{
if ( empty() )
return false;
elem = _stack.back();
_stack.pop_back();
return true;
}
inline bool
Stack::full()
{
return _stack.size() == _stack.max_size();
}
bool
Stack::peek( string &elem )
{
if ( empty() )
return false;
elem = _stack.back();
return true;
}
bool
Stack::push( const string &elem )
{
if ( full() )
return false;
_stack.push_back( elem );
return true;
}
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#include "Stack.h"
int main()
{
Stack blue;
fill_stack(blue,cin);
}
}
#include<string>
using std::string;
class Stack{……};