Group: comp.lang.c++
From: Rob
Date: Sunday, April 13, 2008 10:13 PM
Subject: Re: Can I dynamically create vectors of multiple depths?

On Apr 13, 11:04=A0pm, Rob wrote:
> This actually compiles and works but it doesn't seem like the best
> code, so I was wondering is there another way to do this?
>
> [CODE]
> template vector* addDepth(T)
> {
> =A0 =A0 =A0return new vector;
>
> }
>
> ...a templated meth...
> {
> =A0 =A0 =A0//Create multi-depth vector based on length
> =A0 =A0 =A0void* vec;
> =A0 =A0 =A0int length =3D getLength( obj );
> =A0 =A0 =A0for ( int i =3D 0; i < length; i++ )
> =A0 =A0 =A0{
> =A0 =A0 =A0 =A0 =A0 =A0vec =3D addDepth( someValue );
> =A0 =A0 =A0}
>
> =A0 =A0 =A0vector* b =3D ( vector* ) vec;
>
> }
>
> [/CODE]

Whoops. I meant:

for ( int i =3D 0; i < length; i++ )
{
if ( i =3D=3D 0 ) vec =3D addDepth( someValue );
else vec =3D addDepth( vec );
}