I have a class with a member being a static smart pointer to an object of a different class. Whenever I try to initialize the smart pointer, I always get an error saying "deceleration is incompatible":
Because unique_ptr constructor, which takes pointer, is explicit and cannot be used in this context (and also in implicit conversion context).
Alternative would be:
1 2 3
std::unique_ptr<OtherClass> SomeClass::foo = static_cast<std::unique_ptr<OtherClass>>(new OtherClass);
//or (preferable even over my first post, but requires C++14)
std::unique_ptr<OtherClass> SomeClass::foo = std::make_unique<OtherClass>();