KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In C++, I can write something like: shared_ptr<A> a_sp = someFunctionReturningSharedPtr(); if (a_sp) { cout << a_sp->someData << endl; } else { cout << "Shared Pointer is NULL << endl; } Why does if (a_sp) check work correctly? a_sp is not a boolean, but how is it checked for true or false? How does the if condition know to check the result of a_sp.get() function? Or if it does not, how is the NULL ity of the a_sp checked? Is there some function in shared_ptr defined that converts it to boolean value?
Tags (comma-separated)
Save Edits
Cancel