, , std:: stringstream "" . "< < , / ++. , " "" < < .
< , , , -, , , const, :
friend std::ostream & operator<<( std::ostream & o, const Mystack & stack ) {
for (int i = 0; i <= stack.top; i++)
{
o << stack.input[i] << " ";
}
return o;
}
template <class T>
class Mystack
{
private:
T *input;
int top;
int capacity;
public:
Mystack();
~Mystack();
void push(T const& x);
void pop();
T& topElement() const;
bool isEmpty() const;
void print();
friend std::ostream & operator<<( std::ostream & o, const Mystack & stack ) {
for (int i = 0; i <= stack.top; i++)
{
o << stack.input[i] << " ";
}
return o;
}
};
case 6:
std::cout << "The stack contents: " << s2 << std::endl;
break;