c++ -fpermissive error while implement callback in c++ -
class caller{ private: callbackinterface &m_cb; public: caller(callbackinterface& cb):m_cb(cb){};
doesn't give -fpermissive error whereas following gives. why so?
class caller{ private: callbackinterface &m_cb; public: caller(callbackinterface& cb){ m_cb=cb; };
a reference variable should initialized when declaring. member variable constructed in constructor, should in initialization list .
if trying initialize member reference variable inside constructor, assignment variable should have been defined.
so code has issues in 2 fold
- reference variable not initialized when defined
- reference variable assigned once has been defined inside constructor.