type prob



 DEVELOP > c-Plus-Plus > type prob

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Dave"
Date: 27 Nov 2003 05:05:31 PM
Object: type prob
hi
another simple problem sorry. i've got a string, "Buffer", and an int, Loop.
Somehow, this:
Buffer.length<=Loop+1
gives this:
error C2296: '<=' : illegal, left operand has type 'unsigned int (__thiscall
std::basic_string<char,struct std::char_traits<char>,class std::allocato
r<char> >::*'
Buffer.length should return an int, correct? loop is certainly an int. what
am i doing wrong?
cheers
dave
.

User: "Wouter Lievens"

Title: Re: type prob 27 Nov 2003 02:12:15 AM
"Dave" <davefromalbury_REMOVE_THIS_TO_EMAIL_@hotmail.com> schreef in bericht
news:3fc57821@dnews.tpgi.com.au...

hi

another simple problem sorry. i've got a string, "Buffer", and an int,

Loop.

Somehow, this:

Buffer.length<=Loop+1

gives this:

error C2296: '<=' : illegal, left operand has type 'unsigned int

(__thiscall

std::basic_string<char,struct std::char_traits<char>,class std::allocato
r<char> >::*'

Buffer.length should return an int, correct? loop is certainly an int.

what

am i doing wrong?

cheers
dave

Though compile errors seem cryptic, they mostly speak the truth.
Left operand in this case has a function's type: that's becasue you're not
calling it!
.
User: "Dave"

Title: Re: type prob 28 Nov 2003 12:01:29 AM
sorry i think i'm missing something everone else is seeing. how do i find
the length of the string "Buffer", as an "int" data type?
.
User: "Rolf Magnus"

Title: Re: type prob 27 Nov 2003 05:22:57 AM
Dave wrote:

sorry i think i'm missing something everone else is seeing. how do i
find the length of the string "Buffer", as an "int" data type?

You got the answer already. You must _call_ the function to get its
result. You're comparing the function itself to Loop+1, not the result
of a call to it. Buffer.length gives you the function. Buffer.length()
calls the function and gives you the result.
.
User: "Victor Bazarov"

Title: Re: type prob 27 Nov 2003 11:31:45 AM
"Rolf Magnus" <ramagnus@t-online.de> wrote...

Dave wrote:

sorry i think i'm missing something everone else is seeing. how do i
find the length of the string "Buffer", as an "int" data type?


You got the answer already. You must _call_ the function to get its
result. You're comparing the function itself to Loop+1, not the result
of a call to it. Buffer.length gives you the function. Buffer.length()
calls the function and gives you the result.

Thanks, Rolf.
Now, for the inattentive ones: it's the parentheses.
.
User: "Dave"

Title: Re: type prob 28 Nov 2003 09:15:54 AM
Ahahaha yes i am feeling stupid. Looks like its back to basics for me:
10 PRINT "HELLO WORLD"
20 GOTO 10
cheers
dave
.





User: "Josephine Schafer"

Title: Re: type prob 26 Nov 2003 10:34:39 PM
"Dave" <davefromalbury_REMOVE_THIS_TO_EMAIL_@hotmail.com> wrote in message
news:3fc57821@dnews.tpgi.com.au...

hi

another simple problem sorry. i've got a string, "Buffer", and an int, Loop.
Somehow, this:

Buffer.length<=Loop+1

gives this:

error C2296: '<=' : illegal, left operand has type 'unsigned int (__thiscall
std::basic_string<char,struct std::char_traits<char>,class std::allocato
r<char> >::*'

Buffer.length should return an int, correct? loop is certainly an int. what
am i doing wrong?

No.
Buffer.length returns std::string::size_type and not int.
Try this -
#include <string>
int main()
{
std::string Buffer("abc");
std::string::size_type loop = Buffer.length ();
}
HTH,
J.Schafer
.

User: "Victor Bazarov"

Title: Re: type prob 26 Nov 2003 10:35:55 PM
"Dave" <davefromalbury_REMOVE_THIS_TO_EMAIL_@hotmail.com> wrote...

another simple problem sorry. i've got a string, "Buffer", and an int,

Loop.

Somehow, this:

Buffer.length<=Loop+1

Did you mean to say
Buffer.length()<=Loop+1


gives this:

error C2296: '<=' : illegal, left operand has type 'unsigned int

(__thiscall

std::basic_string<char,struct std::char_traits<char>,class std::allocato
r<char> >::*'

Buffer.length should return an int, correct? loop is certainly an int.

what

am i doing wrong?

You're not calling the function, you're placing its name in the
expression. That's what the compiler is telling you: "Left operand
has type '...<function declaration>...' "
Victor
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER