mardi 27 novembre 2018

Avoid raw new operotor [on hold]

I want to draw a keyboard.

For this purpose, I need to create multiple instanses of object Key and save some data about each key in somewhere. I don't want to user raw operator new and do some thing like this:

std::vector<Key*> keys;
keys.push_back(new Key());

Is it a good idea to save shared_ptr(s) in vector?

std::vector<std::shared_ptr<Key>>

Thanks.

Aucun commentaire:

Enregistrer un commentaire