473,407 Members | 2,546 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,407 software developers and data experts.

explicitly initializing


Given this:

<snip>
typedef std::map<string, QxEvent> QxEventContainerBase;

class QxEventContainer:public QxEventContainerBase{
public:
//!Default constructor
QxEventContainer();
QxEventContainer( const QxEventContainer & ec );
QxEventContainer & operator=( const QxEventContainer& ec );

......
};

QxEventContainer::QxEventContainer( const QxEventContainer & ec ){
*this::
m_interval = ec.m_interval;
}
QxEventContainer & QxEventContainer::operator=( const QxEventContainer&
ec ){
if ( this != &ec ){
m_interval = ec.m_interval;
}
return *this;
}

</snip>
I have a typedef as a base class for a container type class. Now I get a
warning saying that the template *should* be explicitly initialized in
the copy constructor. Now, what does that mean?and how do I fix it.
Thank's for any help.
This is the error I get:

qxeventcontainer.cpp:11: warning: base class `class
map<basic_string<char,string_char_traits<char>,__d efault_alloc_template<true,0>
,QxEvent,less<basic_string<char,string_char_trait s<char>,__default_alloc_template<true,0> > >,__default_alloc_template<true,0> >' should be explicitly initialized in the copy constructor

regards
/B

Jul 19 '05 #1
1 5929
"Bob Smith" <bo******@jippii.fi> wrote...

Given this:

<snip>
typedef std::map<string, QxEvent> QxEventContainerBase;

class QxEventContainer:public QxEventContainerBase{
public:
//!Default constructor
QxEventContainer();
QxEventContainer( const QxEventContainer & ec );
QxEventContainer & operator=( const QxEventContainer& ec );

.....
};

QxEventContainer::QxEventContainer( const QxEventContainer & ec ){
*this::
m_interval = ec.m_interval;
}
QxEventContainer & QxEventContainer::operator=( const QxEventContainer&
ec ){
if ( this != &ec ){
m_interval = ec.m_interval;
}
return *this;
}

</snip>
I have a typedef as a base class for a container type class. Now I get a
warning saying that the template *should* be explicitly initialized in
the copy constructor. Now, what does that mean?and how do I fix it.
Thank's for any help.
This is the error I get:

qxeventcontainer.cpp:11: warning: base class `class
map<basic_string<char,string_char_traits<char>,__d efault_alloc_template<true
,0>
,QxEvent,less<basic_string<char,string_char_trait s<char>,__default_alloc_te

mplate<true,0> > >,__default_alloc_template<true,0> >' should be explicitly
initialized in the copy constructor

std::map<>'s default c-tor is declared "explicit". Since you're
inheriting from std::map, you need to construct the base class
explicitly in the copy c-tor, because if the initialisation is
omitted, the default initialisation is used, and for std::map it
is "explicit".

Victor
Jul 19 '05 #2

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

Similar topics

50
by: Dan Perl | last post by:
There is something with initializing mutable class attributes that I am struggling with. I'll use an example to explain: class Father: attr1=None # this is OK attr2= # this is wrong...
14
by: Avi Uziel | last post by:
Hi All, I'm writing a Windows DLL which contain some utility classes. One of my classes is Singleton, therefore contain some static members. I'm using VC6 and linking to the DLL statically. ...
2
by: Wynne | last post by:
Can anyone here tell me about initializing high-values? I want to create a generic stored procedure that will perform the following Select * from ? where ? between parm1 and parm2 no...
1
by: Mike Davison | last post by:
I've made a program that fetches data from an ODBC data source. Everything works fine when the table contains only a few rows. The problem is that when there are many rows (6000, in this case),...
8
by: SM | last post by:
I've always wonder if there is diference when declaring and initializing a varible inside/outside a loop. What's a better practice? Declaring and initializing variables inside a loop routine,...
38
by: junky_fellow | last post by:
Guys, I was just looking at some code where to initialize an integer with all F's following statement is used; unsigned int i = -1; I want to know if this is the right way of doing the...
10
by: Jason Doucette | last post by:
Situation: I have a simple struct that, say, holds a color (R, G, and B). I created my own constructors to ease its creation. As a result, I lose the default constructor. I dislike this, but...
13
by: WaterWalk | last post by:
Hello. When I consult the ISO C++ standard, I notice that in paragraph 3.6.2.1, the standard states: "Objects with static storage duration shall be zero-initialized before any other...
6
by: Jai Prabhu | last post by:
Hi All, Consider the following piece of code: void func (void) { static unsigned char arr = "\x00\xAA\xBB"; fprintf (stderr, "0x%x\n", arr); fprintf (stderr, "0x%x\n", arr);
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.