There is a code structure I use a lot and I always face the same problem. I have a class which contains several pointers, and every time I copy it, I can't read into my pointers anymore because I'm not using a shared_pointer
and my pointers have been deleted.
class Mesh
{
public:
~Mesh()
{
// Delete all pointers in vertices
...
}
Mesh processOnMesh();
std::vector<Vertex*> vertices;
};
Is there a trick commonly used for this which does not involve using a shared_pointer
? I am asking this because I use a large amount of pointers (10 000 to 100 000) and I don't want to create a new instance for each pointer.
Aucun commentaire:
Enregistrer un commentaire