I have a function getA() with the following signature:
class A {
public:
typedef std::tr1::shared_ptr <A> Ptr;
//other member functions....
};
class B {
public:
A::Ptr getA();
};
And, I want to return an empty pointer in getA() in same case; Also, as a user of Class B , I need to test if the return value of getA() is null before using it. How should I do it?
Note that
A::Ptris private in your sample. You should fix it.To return an empty pointer:
To check it: