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]

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


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