Hi I need to do this but I haven't problem with array (don't compile):
How can I do this? ThanksQt Code:
GLfloat position[4]; GLfloat[] getPosition() {return &position[0]; }To copy to clipboard, switch view to plain text mode
Hi I need to do this but I haven't problem with array (don't compile):
How can I do this? ThanksQt Code:
GLfloat position[4]; GLfloat[] getPosition() {return &position[0]; }To copy to clipboard, switch view to plain text mode
Regards
There are two solutions:Originally Posted by mickeyor more efficient and more dangerous:Qt Code:
GLfloat[4] getPosition() {return position; }To copy to clipboard, switch view to plain text modeQt Code:
GLfloat * getPosition() {return &position[0]; } // or // GLfloat * getPosition() {return position; }To copy to clipboard, switch view to plain text mode
Sorry, your firset solution (I didn't try the second because I don't need a pointer value) give me this error:
Qt Code:
C:\Qt\3.2.0Educational\include\qsignalslotimp.h(66): fatal error C1903: unable to recover from previous error(s); stopping compilationTo copy to clipboard, switch view to plain text mode
Regards
What is the first error?Originally Posted by mickey
Originally Posted by mickeyGuess what it prints...Qt Code:
int arr[4] = {0, 1, 2, 3}; int *arrPtr = arr; printf("%d\n", arrPtr[2]);To copy to clipboard, switch view to plain text mode
There isn't first error..There are many errors after like those:
Qt Code:
error C2061: syntax error : identifier 'getPosition' error C3400: 'string': unexpected token/character encountered in attribute block error C2334: unexpected token(s) preceding '{'; skipping apparent function bodyTo copy to clipboard, switch view to plain text mode
Regards
That's quite interestingOriginally Posted by mickey
You will have to use one of these:Qt Code:
GLfloat * getPosition() {return &position[0]; } // or GLfloat * getPosition() {return position; }To copy to clipboard, switch view to plain text mode
OK. those solution are write. I wondered how I must code the first solution with [].
Thanks
Regards
Bookmarks