Course Solutions Uncategorized (Solved) : C Question Please Detail Thank Much Write Code Keep Object Obj Owns Alive Outside Scope F Q32812762 . . . .

(Solved) : C Question Please Detail Thank Much Write Code Keep Object Obj Owns Alive Outside Scope F Q32812762 . . . .

 

C++ question. Please be detail if you can. Thank you verymuch.

a/Write code to keep the object which obj owns alive outside ofthe scope of func and wPtr reference obj.

b/Write code to test if wPtr is dangling. Is itdangling ornot?

class Name {

public:
Name() {}
private:
string name{ “CS” };
};
weak_ptr<Name> wPtr;
share_ptr<Name> sPtr{nullptr};

void func() {
unique_ptr<Name> obj { make_unique<Name>() };
// #1 Insert Code
}
int main() {
// #2 Insert Code
return 0;
}

Expert Answer


An answer will be send to you shortly. . . . .

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post