RE: Object of abstract type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux