I have a function of type
virtual void foo(bla, bla, bla, std::shared_ptr<LoggerInterface> logger) = 0;
And I want to pass a default parameter with NULL pointer, something like:
virtual void foo(bla, bla, bla, std::shared_ptr<LoggerInterface> logger = NULL) = 0;
So that in implementation, if logger is NULL
I do nothing with it, otherwise I use the logger.
I've tried to look for a solution but cannot find..
UPD: Duplicate claim is irrelevant, I am asking about default NULL parameter.
Is it possible that gcc 4.4 doesn't support nullptr?
nullptr
instead ofNULL
. The latter is a macro that is likely0
, the former is the proper literal for a null pointer. – Quartersaw