By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,204 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,204 IT Pros & Developers. It's quick & easy.

A new syntax (to me)

P: n/a
What does the line :
m_stationDb(stationDB), m_units(units), m_date(date), m_time(time),
m_localUTCOffse(localUTCOffset)
in kweather metarparser.cpp constructor (shown below) mean?
I don't really know C++ and can't find reference to this in my C++ books.
TIA
MetarParser::MetarParser(StationDatabase *stationDB,
KLocale::MeasureSystem units,
QDate date,
QTime time,
unsigned int localUTCOffset) :
m_stationDb(stationDB), m_units(units), m_date(date), m_time(time), m_localUTCOffset(localUTCOffset)
{
CoverRegExp = QRegExp("^(FEW|SCT|BKN|OVC|SKC|CLR|CAVOK)([0-9]{3})?(?:TCU|CB)?$");
CurrentRegExp = QRegExp("^(\\+|-|VC)?([A-Z]{2,4})$");
WindRegExp = QRegExp("^([0-9]{3}|VRB)([0-9]{2,3})(?:G([0-9]{2,3}))?(KT|KMH|MPS)$");
VisRegExp = QRegExp("^([0-9]{1,2})SM$");
VisFracRegExp = QRegExp("^1/(2|4)SM$");
TempRegExp = QRegExp("^(M)?([0-9]{2})/(?:(M)?([0-9]{2}))?$");
TimeRegExp = QRegExp("^([0-9]{2}:[0-9]{2})$");
DateRegExp = QRegExp("^([0-9]{4}/[0-9]{2}/[0-9]{2})$");
PressRegExp = QRegExp("^([AQ])([0-9]{4})$");
TempTenRegExp = QRegExp("^T([01][0-9]{3})([01][0-9]{3})$");
}

Apr 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Duane Evenson wrote:
What does the line :
m_stationDb(stationDB), m_units(units), m_date(date), m_time(time),
m_localUTCOffse(localUTCOffset)
in kweather metarparser.cpp constructor (shown below) mean?
I don't really know C++ and can't find reference to this in my C++ books.

MetarParser::MetarParser(StationDatabase *stationDB,
KLocale::MeasureSystem units,
QDate date,
QTime time,
unsigned int localUTCOffset) :
m_stationDb(stationDB), m_units(units), m_date(date), m_time(time), m_localUTCOffset(localUTCOffset)
{


It's the constructor initializer list. The m_ identifiers are probably
members (the
same syntax is used to initialize base classes, but the m_ suffix is
often
used to distinguish members from base classes).

The advantage of it is that members initialized that way are directly
initialized
with the correct value, and need not have default constructors. Any
member
NOT listed there is default-initialized (which for 'int' means not at
all). You then
have to assign a value in the body of the ctor. Default construction
followed
by assignment might be more expensive.

HTH,
Michiel Salters

Apr 21 '06 #2

P: n/a
Duane Evenson wrote:
What does the line :
m_stationDb(stationDB), m_units(units), m_date(date), m_time(time),
m_localUTCOffse(localUTCOffset)
in kweather metarparser.cpp constructor (shown below) mean?
I don't really know C++ and can't find reference to this in my C++ books.
TIA
MetarParser::MetarParser(StationDatabase *stationDB,
KLocale::MeasureSystem units,
QDate date,
QTime time,
unsigned int localUTCOffset) :
m_stationDb(stationDB), m_units(units), m_date(date), m_time(time), m_localUTCOffset(localUTCOffset)
{
CoverRegExp = QRegExp("^(FEW|SCT|BKN|OVC|SKC|CLR|CAVOK)([0-9]{3})?(?:TCU|CB)?$");
CurrentRegExp = QRegExp("^(\\+|-|VC)?([A-Z]{2,4})$");
WindRegExp = QRegExp("^([0-9]{3}|VRB)([0-9]{2,3})(?:G([0-9]{2,3}))?(KT|KMH|MPS)$");
VisRegExp = QRegExp("^([0-9]{1,2})SM$");
VisFracRegExp = QRegExp("^1/(2|4)SM$");
TempRegExp = QRegExp("^(M)?([0-9]{2})/(?:(M)?([0-9]{2}))?$");
TimeRegExp = QRegExp("^([0-9]{2}:[0-9]{2})$");
DateRegExp = QRegExp("^([0-9]{4}/[0-9]{2}/[0-9]{2})$");
PressRegExp = QRegExp("^([AQ])([0-9]{4})$");
TempTenRegExp = QRegExp("^T([01][0-9]{3})([01][0-9]{3})$");
}


As Mr. Salters indicated, it's an initializer list. Compare this FAQ:

http://www.parashift.com/c++-faq-lit....html#faq-10.6

Cheers! --M

Apr 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.