Question: std::shared _ ptr is used for shared - ownership resource management. Given the following function definition: template void Foo ( std::shared _ ptr sp )

std::shared_ptr is used for shared-ownership resource management. Given the following function definition:
template
void Foo(std::shared_ptr sp){
std::cout << sp.use_count()<< std::endl;
}
What will Foo have written to standard output after the following statements have executed?
auto m1= std::make_shared(7);
Foo(m1);
Note: a shared_ptr's use_count returns the number (i.e., count) of shared_ptr objects engaged shared ownership of the resource pointed to.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!