cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
explicit in class
explicit in class
Nov 7, 2016 at 7:18pm UTC
NavidTak
(16)
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 UTC
Nov 7, 2016 at 8:50pm UTC
AbstractionAnon
(6954)
There's a good explanation here:
http://www.cplusplus.com/forum/general/168292/
Nov 8, 2016 at 12:07am UTC
mbozzi
(3933)
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 UTC
Topic archived. No new replies allowed.