CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: error C2440

  1. #1
    Join Date
    Mar 2006
    Location
    Inida
    Posts
    119

    error C2440

    Hi Gurus,
    Here i have pasted the sample code( i could n't paste the entire code ). when i compiled the code, i got the error
    HTML Code:
     "../TalhAggrApp.C(291) : error C2440: 'initializing' : cannot convert from 'unsig
    ned int (__thiscall talhAggrSchema::*)(void)' to 'unsigned int'
            Conversion is a valid standard conversion, which can be performed implic
    itly or by use of static_cast, C-style cast or function-style cast"
    Following is the code snippet:

    Headerfile

    Code:
     
    namespace environment
    {
    // now we are talking about long long (64 bits) integers.
    typedef long int int8;
    typedef unsigned long int uint8;
    typedef int int4;
    typedef unsigned int uint4;
    typedef short int int2;
    typedef unsigned short int uint2;
    typedef signed char int1;
    typedef unsigned 
    }
    using namespace environment;
    class talhAggrSchema
    {
    uint4 elementID;
    uint4 machineID;
    uint4 taGroupID;
    uint4 taProtoID;
    uint4 taTosID;
    eDirection taDirection;
    string souceAddr_List[50]; //consider of having vector of Addr_List instead of Array
    string dstAddr_List[50]; //consider of having vector of Addr_List instead of Array
    string addr_List[50];
    uint4 proto_number;
    uint4 tos;
    public:
    talhAggrSchema():elementID(0),
    machineID(0),
    taGroupID(0),
    taProtoID(0),
    taTosID(0),
    taDirection(static_cast<eDirection>(UNKNOWN)),
    proto_number(0),
    tos(0)
    { 
    //todo: ganad01 initialize the addr_List
    }
    ~talhAggrSchema() 
    {
    }
    uint4 getelementID(void) { return elementID; }
    void setelementID(uint4 elemID) {elementID = elemID;}
    uint4 getMachineID(void) { return machineID; }
    void setMachineID(uint4 mID) { machineID = mID;}
    uint4 getGroupID(void) { return taGroupID; }
    void setGroupID(uint4 grpID) { taGroupID = grpID; }
    uint4 getProtoID(void) {return taProtoID; }
    void setProtoID(uint4 proID) { taProtoID = proID; }
    void setAddList(talhAggrSchema& record, uint4 viewID, uint4 groupID) {}
    uint4 getTosID(void) { return taTosID; }
    void setTosID(uint4 tosID) { taTosID = tosID; }
    uint4 getDirection(void) { return taDirection; }
    void setDirection( eDirection dir ) { taDirection = dir; }
    uint4 getProtocol(void) { return proto_number; }
    void setProNumber(uint4 proNum) { proto_number = proNum; }
    uint4 getTOS(void) { return tos; }
    void setTos(uint4 tos ) { tos = tos;}
    };
    typedef vector<talhAggrSchema*> VaggrSchemas;
     
    class MultiAggregation
    {
    //holds different aggregation requests read from NH_ELEMENT
    VaggrSchemas aggrSchemaCache;
    //Local cache that holds the raw table content
    //VRawRecord rawRecordCache;
    //Local Cache that stores aggregated data, Live Ex expected format
    VProcessedDataCache aggregationCache;
    DuConnection &conn;
    MultiAggregation() {}
    public:
    MultiAggregation(DuConnection &connection):conn(connection)
    {
    }
    ~MultiAggregation()
    {
    }
    bool setupAllAggrSchemas( void );
    bool setProtocol(talhAggrSchema *as);
    };
    Source File
    Code:
     
    //header file is included
    using namespace environment;
    bool MultiAggregation::setupAllAggrSchemas( void )
    {
    pAggrSchema = new talhAggrSchema();
    setProtocol(pAggrSchema);
    }
     
    bool MultiAggregation::setProtocol(talhAggrSchema *as)
    {
    //DuConnection& conn = DuDatabase::singleInstance ()->getConnection (); todo: ganad01 remove this line
    DuStatement* stmt = conn.createStatement ();
    DuResultSet* rs;
    char query[MAX_QUERY_LENGTH];
    uint4 protoID = as->getProtoID; \\error:2440
    snprintf(query,
    MAX_QUERY_LENGTH,
    "SELECT proto_number FROM %s WHERE proto_id != %d",
    "NH_PROTCOL"
    ,protoID
    );
    stmt->setSQL (query);
    // global::pLog->debug( "setProtocol::Reading NH_PROTCOL" );
    Bool result = stmt->executeSQL (DuStatement::DuAutoAlloc, &rs, 1000);
    CuAssertMsg (result, query);
    bool success = false;
    success = getRecordFromResultSet(rs, as, 1);
    if (!success)
    {
    // todo: ganad01 issue a warning about a failed record
    return false;
    }
    return true;
    } //setProtocol
    can you please help me to understand the cause of error and to eliminate the error.

  2. #2
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: error C2440

    It seems you have a function pointer.

    Try this:

    Code:
    uint4 protoID = (as->*getProtoID)();
    Nobody cares how it works as long as it works

  3. #3
    Join Date
    Jan 2002
    Location
    Houston, TX
    Posts
    1,421

    Re: error C2440

    I believe you need to actually call the function.
    Change
    Code:
    uint4 protoID = as->getProtoID; \\error:2440
    to
    Code:
    uint4 protoID = as->getProtoID();
    Hope that helps.
    Be sure to rate those who help!
    -------------------------------------------------------------
    Karl - WK5M
    PP-ASEL-IA (N43CS)
    PGP Key: 0xDB02E193
    PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

  4. #4
    Join Date
    Mar 2006
    Location
    Inida
    Posts
    119

    Re: error C2440

    hi krmed,
    Thanks a Ton!
    Thanks a Ton!
    Thanks a TON!

    My eyes could not catch, yes, i am required to call the function.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured