dimanche 21 février 2021

How do I move a pointer in a vector of pointers to another index in that vector?

I am working on a project in C++ and I have a vector of pointers of a class I made

The vector is size 64 and contains pointers of type L

Suppose the vector is called v

Suppose I have Pointer 1 in the first index of the vector (v.at(0))

I want to move Pointer 1 to the second index of the vector (v.at(1))

Here comes my current code:

v.at(1) = v.at(0);

First question: is this the correct way to set the second index to hold the pointer currently stored in my first index ?

Second question: how do I stop my first index from holding my pointer ?

Thank you in advance ! :D

Aucun commentaire:

Enregistrer un commentaire