#include<iostream> #include<memory> using namespace std; class Logger { public: void log() { cout<<"Logging data"<<endl; } }; int main() { shared_ptr<Logger> sLogger_1 = make_shared<Logger>(); shared_ptr<Logger> sLogger_2 = sLogger_1; sLogger_1->log(); sLogger_2->log(); // cout<<"The reference counter of sLogger_1 is "<<sLogger_1.use_count()<<endl; //cout<<"The reference counter of sLogger_2 is "<<sLogger_2.use_count()<<endl; return 0; }
Test Cases
Test Results
Input
Expected Output
Logging data Logging data