I have the following class definition:
template<typename QueueItemT>
class QueueBC
{
protected:
QueueBC() {}
virtual ~QueueBC() {}
private:
virtual IItemBuf* constructItem(const QueueItemT& item) = 0;
}
I created the following sub-class:
class MyQueue
: public QueueBC<MyItemT>
{
public:
MyQueue() {}
virtual ~MyQueue() {}
};
This compiles fine under VS2005, yet I haven't implemented constructItem()
in the MyQueue
class. Any idea why?
Try using it:
MyQueue m;
You can't instantiate an abstract class, but you can define one (obviously, as you defined QueueBC
). MyQueue
is just as abstract.
For example:
struct base // abstract
{
virtual void one() = 0;
virtual void two() = 0;
};
struct base_again : base // just as abstract as base
{
};
struct foo : base_again // still abstract
{
void one() {}
};
struct bar : foo // not abstract
{
void two() {}
};