Object of abstract type

benjamin benjamin.batistic@triera.net
Thu Jul 19 16:02:00 GMT 2007


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



More information about the Gcc-help mailing list