explicit in class

Nov 7, 2016 at 7:18pm
i was reading a source and hit to following syntax
in a class

1
2
3
4
5
6
7
8
 class Hello {

	public:
		explicit Hello(){}



};

why the person who has written this class use this syntax?
Last edited on Nov 7, 2016 at 7:20pm
Nov 7, 2016 at 8:50pm
There's a good explanation here:
http://www.cplusplus.com/forum/general/168292/
Nov 8, 2016 at 12:07am
It's useless because there are no parameters to the default constructor.
If the constructor marked explicit has parameters, then it will work normally.
Last edited on Nov 8, 2016 at 12:09am
Topic archived. No new replies allowed.