how to copy the value in a const data member


Hey,
I'm having some trouble using the result returned by a "const" member function. Specifically, I'm iterating through a list of _bstr_t strings (_bstr_t is the type of one of the fields in my ADO recordset) and I want to store the length of the longest _bstr_t.
But, a statement like this one:

if (myBstr.length > currentMaxLength)
currentMaxLength = myBstr.length;

produces compiler error:

error C2440: '=' : cannot convert from
'unsigned int(__thiscall _bstr_t::*)(void) const' to 'int'

I've tried to cast myBsrt to an int, to an unsigned int, etc. I'm confused as to why this is incorrect because I simply want to make a copy of the value in myBstr.length - I'm not trying to change the const data member! Any help would be much appreciated.

Macmood

Comments

  • [b][red]This message was edited by HK_MP5KPDW at 2002-8-14 13:9:33[/red][/b][hr]
    [blue]My guess? See the quick comment in [red]red[/red] below.[/blue]
    :
    : Hey,
    : I'm having some trouble using the result returned by a "const" member function. Specifically, I'm iterating through a list of _bstr_t strings (_bstr_t is the type of one of the fields in my ADO recordset) and I want to store the length of the longest _bstr_t.
    : But, a statement like this one:
    :
    : if (myBstr.length[red]()[/red] > currentMaxLength)
    : currentMaxLength = myBstr.length[red]()[/red];
    :
    : produces compiler error:
    :
    : error C2440: '=' : cannot convert from
    : 'unsigned int(__thiscall _bstr_t::*)(void) const' to 'int'
    :
    : I've tried to cast myBsrt to an int, to an unsigned int, etc. I'm confused as to why this is incorrect because I simply want to make a copy of the value in myBstr.length - I'm not trying to change the const data member! Any help would be much appreciated.
    :
    : Macmood
    :
    :



  • :
    : Hey,
    : I'm having some trouble using the result returned by a "const" member function. Specifically, I'm iterating through a list of _bstr_t strings (_bstr_t is the type of one of the fields in my ADO recordset) and I want to store the length of the longest _bstr_t.
    : But, a statement like this one:
    :
    : if (myBstr.length > currentMaxLength)
    : currentMaxLength = myBstr.length;
    :
    : produces compiler error:
    :
    : error C2440: '=' : cannot convert from
    : 'unsigned int(__thiscall _bstr_t::*)(void) const' to 'int'
    :
    : I've tried to cast myBsrt to an int, to an unsigned int, etc. I'm confused as to why this is incorrect because I simply want to make a copy of the value in myBstr.length - I'm not trying to change the const data member! Any help would be much appreciated.
    :
    : Macmood
    :


    Also try using the dot operatory (member class operator) in "CurrentMaxlength().
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories