Hi I am trying to create this pointer, is this a correct way?
Pointer that I have:
class listaFiguras {
//Atributos
int numElementos;
figuraGeom **lista = new (figuraGeom*)[0];
public :
//Constructor sin parametros
listaFiguras();
//Destructor
~listaFiguras();
//Sets y Gets
void setnumElementos(int);
virtual void setLista(figuraGeom**);
int getnumElementos();
virtual figuraGeom* getLista();
//Vaciar lista
void vaciarLista();
//Añadir elemento
void anyadirElemento(figuraGeom *);
};
This is what I have to do:
List: pointer to pointer to FIG. Points to a dynamic array, each element of which is a pointer to FIG.
Thank you in advance !
If you want to allocate everything from scratch, you could take
FIG ** list = new (FIG*)[number_of_pointers];
for(uint i = 0; i<number_of_pointers; ++i)
{
//Set pointer to a new FIG object.
list[i] = new FIG(constructor_arguments);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.