Howdy, Stranger!

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

Categories

how to copy the value in a const data member

macmoodmacmood Member Posts: 11

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

  • HK_MP5KPDWHK_MP5KPDW Member Posts: 770 ✭✭✭
    [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
    :
    :



  • beirowerribeirowerri Member Posts: 109
    :
    : 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().
  • Justin BibJustin Bib USAMember Posts: 0

    ______ / http://forcoder.org / free ebooks and video tutorials about / JavaScript C# MATLAB Perl Swift C Java Visual Basic Scratch Visual Basic .NET PL/SQL Assembly Delphi R Python C++ Go Ruby PHP Objective-C ABAP Rust Dart Awk Erlang Lisp FoxPro SAS Julia Fortran Logo Crystal Bash COBOL D Ada ML Kotlin Apex LabVIEW Lua Transact-SQL Clojure Alice F# Prolog Scheme Scala VBScript Hack / _____

Sign In or Register to comment.