[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Weird "const"-ness problem
From:       Michael Goffioul <goffioul () imec ! be>
Date:       2002-02-13 9:29:44
[Download RAW message or body]

Could anybody enlighten me on the following problem?

In KPrinter class, there's a const function defined as

const QString& KPrinter::option(const QString& key) const
{ return d->m_options[key]; }

where d->m_options is a QMap<QString,QString>. Normally, the
"const" attribute of this function should prevent the map from
creating an empty entry in the map. I then have another class
KPrinterImpl that is a friend of KPrinter. The problem is that
when I call "printer->option(key)" somewhere in KPrinterImpl
code, an empty key is created in the map, though the function
is declared with "const". Why?

Is this because of the "friendness" of KPrinterImpl?
Is this because option() returns a reference instead of a plain
QString object?

Any help appreciated.

Michael.

-- 
------------------------------------------------------------------
Michael Goffioul		IMEC-DESICS-MIRA
e-mail: goffioul@imec.be	(Mixed-Signal and RF Applications)
Tel:    +32/16/28-8510		Kapeldreef, 75
Fax:    +32/16/28-1515		3001 HEVERLEE, BELGIUM
------------------------------------------------------------------
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic