This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]