473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

explicit keyword

Hello everyone,
I am reading the C++ Programming Language book, but can not find the
function of explicit keyword of constructor. Could anyone explain its
usage or refer some learning materials please?
thanks in advance,
George
Dec 11 '07 #1
4 3053
George2 wrote:
I am reading the C++ Programming Language book, but can not find the
function of explicit keyword of constructor. Could anyone explain its
usage or refer some learning materials please?
Have you tried googling?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 11 '07 #2
In article
<ea**********************************@e23g2000prf. googlegroups.com>,
George2 <ge*************@yahoo.comwrote:
Hello everyone,
I am reading the C++ Programming Language book, but can not find the
function of explicit keyword of constructor. Could anyone explain its
usage or refer some learning materials please?
thanks in advance,
George
The "explicit" keyword is defined in 12.3.1:

"An explicit constructor constructs objects just like non-explicit
constructors, but does so only where the
direct-initialization syntax (8.5) or where casts (5.2.9, 5.4) are
explicitly used."

In other words, implicit conversion of the constructor's parameter is
turned off when a constructor is declared explicit.

-dr
Dec 11 '07 #3
On Mon, 10 Dec 2007 22:00:36 -0800 (PST) in comp.lang.c++, George2
<ge*************@yahoo.comwrote,
>I am reading the C++ Programming Language book, but can not find the
function of explicit keyword of constructor.
Section 11.7.1
Dec 11 '07 #4
George2 wrote:
Hello everyone,
I am reading the C++ Programming Language book, but can not find the
function of explicit keyword of constructor.
Have you tried the index?

--
Ian Collins.
Dec 11 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stub | last post by:
Docs says that "The compiler does not use an explicit constructor to implement an implied conversion of types. It's purpose is reserved explicitly for construction." I put up code of three cases...
12
by: Marcelo Pinto | last post by:
Hi all, In practice, what is the diference between a default constructor and an explicit default constructor? class Ai { public: Ai() {} };
8
by: kevin | last post by:
I have a form and in the form I have a sub that uses a class I instantiate using visual basic code: Public oCP As New Rs232 'instantiate the comm port I need to share this sub with...
2
by: Fred Zwarts | last post by:
Consider the following code: // Start of code class MyException_t { public: // Default constructor.
1
by: petschy | last post by:
hello, i've run into an error when qualifying a copy ctor 'explicit'. the strange thing is that i get a compiler error only if the class is a template and declare the variable as X<Zx = y....
10
by: jlongstreet | last post by:
Please correct any misconceptions, or voice concerns about this being a stupid idea in general. I was wondering today: why doesn't C++ have explicit typedefs? explicit typedef unsigned int...
1
by: denis | last post by:
Hello, I noticed the following in the "C++ Coding Standards" book. Why should the code on line 30 be in error? Transmogrify accepts a (B obj), and we are passing it a B obj. I understand why...
5
by: subramanian100in | last post by:
In the standard library vector, the ctor explicit vector::vector(size_type __n) is declared as explicit. I am unable to get the reason for it being declared as explicit. Kindly clarify with an...
12
by: Rahul | last post by:
Hi Everyone, I have the following code and i'm able to invoke the destructor explicitly but not the constructor. and i get a compile time error when i invoke the constructor, why is this so? ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.