473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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
Jul 22 '05 #1
7 2031

"Dave" <da**********************************@hotmail.co m> wrote in message
news:3f******@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

Jul 22 '05 #2
"Dave" <da**********************************@hotmail.co m> 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
Jul 22 '05 #3
"Dave" <da**********************************@hotmail.co m> schreef in bericht
news:3f******@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!

Jul 22 '05 #4
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?
Jul 22 '05 #5
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.

Jul 22 '05 #6
"Rolf Magnus" <ra******@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.
Jul 22 '05 #7
Ahahaha yes i am feeling stupid. Looks like its back to basics for me:

10 PRINT "HELLO WORLD"
20 GOTO 10

cheers
dave
Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: josephrthomas | last post by:
hi..i am trying to make a login page and i am using access table.. when the user enters his userid and password i want to check the password from the table.. if any user with the userID that is...
5
by: Arun Wadhawan | last post by:
Hello MY SQL Server is causing me this problem : Microsoft VBScript runtime error '800a000d' Type mismatch: 'ident' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> I am getting from...
3
by: H. S. | last post by:
Hi, I am trying to compile these set of C++ files and trying out class inheritence and function pointers. Can anybody shed some light why my compiler is not compiling them and where I am going...
0
by: Oliver | last post by:
hi - I'm trying to set Properties dynamically (web forms). The problem is that I can't seem to set the property value based on a string - even though I know the Type of the Property. I seem...
1
by: brittogladez | last post by:
Hi Friends, Please carefully go through my prob which is listed below and give me a solution. Server Error in '/<Appname>' Application....
0
Savage
by: Savage | last post by:
I'm making for fun a simple program which format a input file.Input file sustain of person name,lastname and date of birth.Output file si supposed to be forammted as following: NAME ...
2
by: mnacw | last post by:
Can anybody help me to resolve this prob. i have installed Visual Studio 2005 Professional edition. I am working in VB.Net. When I tried to connect to database it is connected but when i make some...
4
by: Schkhan | last post by:
Hi, I am sturggling with a peace of code mainly its about casting a pointer to one type of structure to a pointer to another type of structure. the confusion begins with the following...
6
by: samsneelam | last post by:
Hi.. This is samuel, while doing a program, i encountered this problem.. Let me give you clarity regarding my prob.. I am having two files .. one is mpcplib.h it contains the follwing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.