std::tr1::shared_ptr<abstractFoo> Baz::staticField( nullptr );
std::tr1::shared_ptr<abstractFoo> Baz::staticField(static_cast<abstractFoo *>(nullptr));
C++ (Qt)#include <iostream>#include <memory> class AbstractClass{public: virtual void makeSomething() = 0;}; class DerivFromAbstract : public AbstractClass{ virtual void makeSomething() { std::cout<<"Make somesing from DerivFromAbstract"<<std::endl; }}; class WithAbstractSmartPtr{public: static std::shared_ptr<AbstractClass> p1;}; //std::shared_ptr<AbstractClass> WithAbstractSmartPtr::p1 = std::shared_ptr<AbstractClass>(nullptr);std::shared_ptr<AbstractClass> WithAbstractSmartPtr::p1(nullptr); int main(){ WithAbstractSmartPtr tst; if( !tst.p1 ) std::cout<<"wrong pointer"<<std::endl; else { std::cout<<"good pointer"<<std::endl; tst.p1->makeSomething(); } WithAbstractSmartPtr::p1 = std::shared_ptr<AbstractClass>(new DerivFromAbstract); if( !tst.p1 ) std::cout<<"wrong pointer"<<std::endl; else { std::cout<<"good pointer"<<std::endl; tst.p1->makeSomething(); } return 0;}
CONFIG += c++11
QMAKE_CXXFLAGS += -std=c++0x