This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Object of abstract type
- From: benjamin <benjamin dot batistic at triera dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 19 Jul 2007 18:04:19 +0200
- Subject: Object of abstract type
Hi!
Is it possible somehow to construct an array of objects of abstract
type?
This is the illustration of what i am trying to do:
class A
{
...
};
class B1 : public A
{
...
};
class B2 : public A
{
...
};
int main()
{
int n;
A *array = new A[n];
...
B object;
array[int i] = object;
...
}
I am aware that an object of virtual class can not be allocated. But, is
my idea solvable in a simple manner?
Thanks!
Benjamin Batistic