-
December 7th, 2008, 03:47 PM
#1
[RESOLVED] Cannot Instantiate abstract Object?
Hi,
I'm working on a project for school, and I'm getting an error that doesn't make sense to me. Here's the code where the error comes from, with the error inserted to the side:
#include "Stack.h"
#include "Array.h"
//#include "Iterator.h"
class StackAsArray: public virtual Stack
{
private:
Array<Object*> theArray; <---------- Error C2259:
Array<T> cannot instantiate abstract class
class Iter;
public:
StackAsArray(unsigned int);
Object& Top();
void Push(Object&) = 0;
Object& Pop();
void Purge();
virtual ~StackAsArray();
friend class Iter;
};
Object is, in fact, abstract, but I'm not instantiating the object, just a pointer to it. Object is the base class from which all other classes derive from, and I want to be able to store an array of them, regardless of specific type. The above code snippet is actually the solution suggested in my textbook. What am I missing? Is there a better way?
Thanks,
jesse
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|