|
| | Subject: | RE: Object of abstract type | | Group: | Gcc-help | | From: | Young, Michael | | Date: | 19 Jul 2007 |
This is a C++ question, not a GCC question - a better forum would be
comp.lang.c++ or something similar...
> Is it possible somehow to construct an array of objects of abstract
> type?
No. The compiler needs to have a constructible, concrete type so it
knows how much space to allocate.
> I am aware that an object of virtual class can not be allocated. But, is
> my idea solvable in a simple manner?
Yes. Create an array of ptrs. to the abstract type, and separately
initialize each entry to an object (or 0/NULL).
BTW - I recommend the use of std::vector over arrays where possible.
- Mike
|