Click on stack.h to get source.
// File: C++Examples/Stacks/stack.h
#ifndef __stack
#define __stack
#include <iostream>
// This is the abstract class
class stack {
public:
stack () {}
virtual bool is_empty(void) const // = 0;
{std::cout <<
"Subclass must implement is_empty" << std::endl;
return true;}
virtual void push(int) // = 0;
{std::cout <<
"Subclass must implement push" << std::endl;
}
virtual int pop(void) // = 0;
// concept demo'd: pure virtual member functions
{std::cout <<
"Subclass must implement pop" << std::endl;
return 0;
}
virtual stack* clone(void) const // = 0;
// concept demo'd: copy of abstract object
// ("clone" is the Java copy)
{std::cout <<
"Subclass must implement clone" << std::endl;
return new stack(*this); // return something reasonable
}
virtual ~stack() {};
// concept demo'd: virtual destructor
};
std::ostream& operator<<(std::ostream&, const stack&);
#endif