jeudi 29 octobre 2015

How to take ownership of std::unique_ptr and std::shared_ptr

This is follow-up question for this.

How do we take ownership of a std::unique_ptr or std::shared_ptr?

Is there a way to to keep b alive?

class A{
   A() {
        b = std::unique_ptr<char[]>(new char[100] { 0 });
   }
private:
 char* b;
}

void func {
   A a;
}

Aucun commentaire:

Enregistrer un commentaire