473,385 Members | 2,243 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.

explict keyword for empty constructors ?

Hi All,

While going through xalan's XSLT source code, I came across few
constructors which are qualified as "explicit". These constructors are
empty constructors.

I read about the use of explict when constructors accept single
argument and it is to avoid accidental conversion from parameter type
to class type.

I am unable to find the significance of explicit keyword for a
constructor that does not accept any arguments all.

Can any of you throw more light on this please ?

For example,

class XalanDOMString
{
explicit XalanDOMString();
};
Jul 22 '05 #1
4 1987
Ganesh Gella wrote:
While going through xalan's XSLT source code, I came across few
constructors which are qualified as "explicit". These constructors are
empty constructors.
You mean, "default constructors", I gather.
I read about the use of explict when constructors accept single
argument and it is to avoid accidental conversion from parameter type
to class type.

I am unable to find the significance of explicit keyword for a
constructor that does not accept any arguments all.

Can any of you throw more light on this please ?

For example,

class XalanDOMString
{
explicit XalanDOMString();
};


There is no significance. A few months back there was a discussion on
this subject in c.l.c++.m and the result, IIRC, was that 'explicit' has
no effect on a c-tor with the number of arguments other than 1.

V
Jul 22 '05 #2
Ganesh Gella wrote:

I am unable to find the significance of explicit keyword for a
constructor that does not accept any arguments all.


As near as I know, it's not illegal to say "explicit" there.
It however, has no defined behavior on any constructor that
isn't a converting constructor (one that can be called with
exactly one args, including multiarg'd constructors that have
defaulted args).
Jul 22 '05 #3
Victor Bazarov wrote:

There is no significance. A few months back there was a discussion on
this subject in c.l.c++.m and the result, IIRC, was that 'explicit' has
no effect on a c-tor with the number of arguments other than 1.

It can have an effect on constructors that take more than one
argument:
class T {
public:
explicit T(int a, int b = 0);
};

The constructor above would be a converting constructor without the
explicit qualifier.
Jul 22 '05 #4
Ganesh Gella wrote:
Hi All,

While going through xalan's XSLT source code, I came across few
constructors which are qualified as "explicit". These constructors are
empty constructors.

I read about the use of explict when constructors accept single
argument and it is to avoid accidental conversion from parameter type
to class type.

I am unable to find the significance of explicit keyword for a
constructor that does not accept any arguments all.

Can any of you throw more light on this please ?

For example,

class XalanDOMString
{
explicit XalanDOMString();
};


If you think more on it, you will realise that all other constructor
uses are explicit (including the default constructor).

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #5

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

Similar topics

5
by: Jeff Grundy | last post by:
Is there any difference between these 3 ways of using the NEW keyword? Which is prefered? Dim xlApp As New Excel.Application Dim xlApp As Excel.Application = New Excel.Application Dim xlApp...
2
by: Ganesh Gella | last post by:
Hi all, I have seen few places where constructors are declared like this. class A { explicit A(){}; }; I can understand this, class A {
3
by: Ben Galvin | last post by:
Hi, I'm looking for an equivalent to the C++ 'friend' keyword in C# (for those who don't know, this lets you give a specific class access to all the private/protected members of another class)....
4
by: Gecko | last post by:
I noticed that every time I override a class member, the intellisense behavior is to automatically add a call to the base class of the overridden member such as: public override void...
5
by: Water Cooler v2 | last post by:
Does the *this* keyword refer to the class or the instance?
3
by: flat_ross | last post by:
For anyone who is just getting into VB.NET and/or is starting to work with inheritance I would like to point out a potential pitfall. We found this confusion recently when code-reviewing an...
6
by: Christopher Lusardi | last post by:
How can I fix this? When I do the below I get the error message: "Cannot insert explict value for identity column in table 'Employees' when IDENTITY_INSERT is set to OFF." To get this message,...
9
by: 440gtx | last post by:
The class keyword created a lot of confusion that resulted in a popular style that says struct is appropriate for POD (plain old data) and class is appropriate for fancier things (member functions,...
4
by: George2 | last post by:
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...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.