Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7540905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:45:21+00:00 2026-05-30T07:45:21+00:00

I am getting an error about the return statement (or cast) in the final

  • 0

I am getting an error about the return statement (or cast) in the final function in the following extract from a library header

///////////////////////////////////////////////////////////
// class __HashMapDefaultProviderT

/**
* @internal
* @class    __HashMapDefaultProviderT
* @brief    This is an implementation of the IHashCodeProviderT interface for the HashMap class.
* @since    1.0
*/
template<class KeyType>
class __HashMapDefaultProviderT
    :   public IHashCodeProviderT<KeyType>,
    public Object
{
public:

    // Lifecycle

    /**
    * This is the default constructor for this class.
    *
    * @since     1.0
    */
    __HashMapDefaultProviderT(void) {}


    /**
    * This is the destructor for this class.
    *
    * @since     1.0
    */
    virtual ~__HashMapDefaultProviderT(void) {}


    // Operation

    /**
    * Gets the hash code of the specified object
    *
    * @since        1.0
    * @return       The hash code of the specified object
    * @see          Osp::Base::Object::GetHashCode
    */
    int GetHashCode(const KeyType& obj) const
    {
        return (int)obj;
    }


};

the error is:

invalid cast from type ‘const myClass’ to type ‘int’

What is the fix for this? The header file is called FBaseColHashMapT.h

I’ve added operator> and operator< methods already but I don’t know how else to get my class to hash or how to permit the cast that is required above, short of inheriting it, but I’d like to see if I can avoid that. To support those two operators I wrote:

inline int GetHashCode() const {return myIntMember/4 + clientRect.GetHashCode();}

Maybe it could be of re-use again here?

I am supplying myClass as the key to this template class and int as the value.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:45:22+00:00Added an answer on May 30, 2026 at 7:45 am

    Obviously the class expects the KeyType (in your case myDescriptor) to be convertible to int. Therefore the fix would be to add that conversion to myDescriptor:

    class myDescriptor
    {
    public:
      operator int() const { return (whatever the library expects, probably a hash key); }
      // ...
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting an error about incorrect html when I return from the Save
I am getting an error about the assembly C:\Ora10g\bin\Zip.exe. The trouble is this solution
I am doing a recursive program and I am getting an error about conflicting
OK I keep getting this error after about 3-4 minutes of churning: Timeout expired.
i am getting this error does some one knows about it??? 2009-07-08 18:42:36.778 FlashCards[1297:20b]
I wrote following code...but i am getting Error like: Error 1 'LoginDLL.Class1.Login(string, string, string)':
I'm getting an error (well, a ton of errors actually) from valgrind that I'm
I'm using JQuery from Google CDN and I've been getting stack overflow error (using
I keep getting this error about my sql database NEW ERROR 07-03 01:52:08.037: ERROR/AndroidRuntime(627):
I am getting the Error/Warning about a part of my code saying 'Messages Without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.