[Qt-interest] Problem with passing reference parameters

Denton Vis vistapro7 at hotmail.com
Sat Mar 7 00:57:28 CET 2009


Hi guys,
I do realize that this may be more of a C++ question. But as I have 
encountered it while working with Qt, I will ask it here.
gcc allows Qt to have functions like:
                void writeNamespace ( const QString & namespaceUri, const 
QString & prefix = QString() )
As well as to pass object where references are required.

But when I do write a function e.g.
                void doSomething(std::string & s);
and I make a call to it using:
                doSomething(QString("test").toStdString()) or
                doSomething(std::string("test"));
the compiler complains very loudly about not finding the function 
definition:
                doSomething(std::string )
and tells me to try:
                doSomething(std::string &)

I must therefore first create a temporary variable and then pass it as a 
reference.

am I missing something?

Thanks! 




More information about the Qt-interest-old mailing list