Wednesday, October 15th 2008, 10:06pm UTC+1

You are not logged in.

  • Login
  • Register

1

Tuesday, April 15th 2008, 7:48am

Problem in QString assignment

Hi,
I am facing a problem in assigning a '0' value to string in header file declaration.

I have a header file A.h

Source code

1
2
3
//A.h 

void show(const QString s& = 0,int = 0 );


but here compiler is giving error as :

Quoted


error: default argument for parameter of type 'const QSring&' has type 'int'



I am using gcc version 4.2.1 . I have also used NULL but the result were same.

Where is the problem ??

Can any body help ??
  • Go to the top of the page

Messenger

Intermediate

Posts: 413

Location: Lt

2

Tuesday, April 15th 2008, 8:36am

RE: Problem in QString assignment

imho must be something like

Source code

1
2
3
4
5
6
7
8
void show(const QString& s = QString::null, int i = 0 );
 //or
//void show(const QString& s = QString(), int i = 0 );
// or
//void show(const QString& s = "0", int i = 0);

void show(const QString& s, int i)
{}

See QString constructors.
Fighting fire with fire.
  • Go to the top of the page

3

Wednesday, April 30th 2008, 8:31pm

RE: Problem in QString assignment

You can also use QString::number(0)
  • Go to the top of the page

Rate this thread