A.3 - 16 Points - class Name public: Name() 0 Name(string name) { this->name = name; } -Name() { cout << this->name << "

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

A.3 - 16 Points - class Name public: Name() 0 Name(string name) { this->name = name; } -Name() { cout << this->name << "

Post by answerhappygod »

A 3 16 Points Class Name Public Name 0 Name String Name This Name Name Name Cout This Name 1
A 3 16 Points Class Name Public Name 0 Name String Name This Name Name Name Cout This Name 1 (100.22 KiB) Viewed 71 times
A 3 16 Points Class Name Public Name 0 Name String Name This Name Name Name Cout This Name 2
A 3 16 Points Class Name Public Name 0 Name String Name This Name Name Name Cout This Name 2 (23.95 KiB) Viewed 71 times
A.3 - 16 Points - class Name public: Name() 0 Name(string name) { this->name = name; } -Name() { cout << this->name << ": Destructor called." << endl; } string getName() const { return this->name; } private: string name{ "N/A" }; }; void passByMove(const unique_ptr<Name> uptr_M) { cout << "@uptr_M: "<< uptr_M<< endl; cout << "getName(): " << uptr_M->getName() << endl; } void passByRef(const unique_ptr<Name>& uptr_R) { cout << "@uPtr_R:"<<uPtr_R<<endl; cout << "getName(): " << uptr_R->getName() << endl; } void passByShare(const shared_ptr<Name> sPtr_S) { cout << "@sptr_S:"<<sptr_s << endl; cout << "getName():" << sptr_S->getName() << endl; cout << "use_count(): "<<sptr_s.use_count() << endl; } Name* passByValue(const unique_ptr<Name> uptr_V){ cout << "@uptr_V: "<< uptr_V«<endl; cout << "getName(): "<< uptr_V->getName() << endl; return uptr_V.get(); } int main() { cout << passByValue(make_unique<Name>("Goofy")) << endl; unique_ptr<Name> uPtr{ make_unique<Name>("Mickey") }; passByRef(uptr); cout << "name_uptr:" << uPtr << endl; passByMove(move(uptr)); cout << "name_uptr: " <<uPtr << endl; uPtr = make_unique<Name>("Minnie"); shared_ptr<Name> sPtr{ uPtr.release() }; passByShare(sptr); cout << "END of Program" << endl; return 0; }

How many lines does this program output? Please give the output of the program. Use @A, @B, @c, @D, and nullptr to represent memory addresses. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply