cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
user name:
password:
Forgot your password?
please wait
try again
cancel
forgot your password?
sign up
log in
[Legacy version]
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
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
Nov 7, 2016 at 7:20pm UTC
Nov 7, 2016 at 8:50pm
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
Nov 8, 2016 at 12:07am UTC
mbozzi
(3943)
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
Nov 8, 2016 at 12:09am UTC
Topic archived. No new replies allowed.