I want to have a static variable, such that I can assign a std::shared_ptr object to it when I construct the class. What I tried was the following which did not work.
class CLS
{
static std::shared_ptr<spdlog::logger> log;
static unsigned int p;
public:
CLS(const unsigned int input1 = 1,
const std::shared_ptr<spdlog::logger>& logger=nullptr)
{
if (logger != nullptr) {
log = logger;
}
p = input1;
}
~CLS()
{
}
};
I could do it for example for and integer object like above but not shared_ptr.
The reason I want this is that for a functionality, when I construct this class without the "logger" input, I want the "log" static variable to be available for use.