Actually my question is all in the title.
Anyway:
I have a class and I use explicit constructor:
.h
class MyClass { public: explicit MyClass(const string& s): query(s) {} private: string query; }
Is it obligatory or not to put explicit keyword in implementation(.cpp) file?
No, it is not. The
explicitkeyword is only permitted in the header. My gcc says:for the following code: