Hey there,
for some reason, if i have a function which has QString Arguments and I pass it a char*, sometimes it works and sometimes I get an Error?
Why is this and how to work around?
Hey there,
for some reason, if i have a function which has QString Arguments and I pass it a char*, sometimes it works and sometimes I get an Error?
Why is this and how to work around?
What error?I get an Error?
Can you paste it here?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
The function declaration:
Qt Code:
To copy to clipboard, switch view to plain text mode
How I call it:
Qt Code:
To copy to clipboard, switch view to plain text mode
The Error I get:
Qt Code:
/home/finn/client_gallery/dirparser.cpp:24: error: no matching function for call to ‘SqlViaHttp::select(const char [5], QString&)’To copy to clipboard, switch view to plain text mode
//EDIT:
Ahh, ok, I know so the solution.
I have to use QString instead of QString& in the Declaration.
Why is that?
Last edited by kingfinn; 12th March 2010 at 17:51.
You don't have to change the declaration, you can change the way you use call the function.I have to use QString instead of QString& in the Declaration.
Why is that?
You declared it with a reference, so you need to pass a reference, but you have passed a literal string.
Your declaration will work if you call it like this:
Qt Code:
To copy to clipboard, switch view to plain text mode
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Bookmarks