This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Object of abstract type
- From: "Young, Michael" <Michael dot Young at paetec dot com>
- To: "benjamin" <benjamin dot batistic at triera dot net>, <gcc-help at gcc dot gnu dot org>
- Date: Thu, 19 Jul 2007 12:17:11 -0400
- Subject: RE: Object of abstract type
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