We have already defined a class Logger with a method:
void log() { cout << "Logging data\n"; }
Your task is to:
shared_ptr<Logger>
main()
log()
Example
Output:
Logging data Logging data
Why this output?
Both shared pointers (p1 and p2) point to the same Logger object, so calling log() through each produces two identical lines.
Question Significance
This demonstrates how multiple smart pointers can share ownership of a single object, unlike unique_ptr which has only one owner.
Test Cases
Test Results
Input
Expected Output