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 3442166
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:38:12+00:00 2026-05-18T08:38:12+00:00

I have the following declaration to distinct that it uses different operations in my

  • 0

I have the following declaration to distinct that it uses different operations in my code:

typedef unsigned int SOMEIDTYPE;

Now when i create two overloaded functions:

string something(const unsigned int &val){ ... itoa(val) ... }
string something(const SOMEIDTYPE &val){ ... IDTABLE[val] ... }

I get error: error C2084: function 'std::string something(const unsigned int &)' already has a body

So, How can i overload this function to use those two different datatypes distinctively, and perform different operations as seen above?

Edit: The reason for overloading is that i am calling this function inside a template function.

  • 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-18T08:38:13+00:00Added an answer on May 18, 2026 at 8:38 am

    A typedef only creates a nickname — it doesn’t create a new type.

    If you really want to do something like this, then you need to create a new type. You could create a class for this purpose, but in order for that class to behave like an int, you’d need to do some work:

    class SOMEIDTYPE
    {
    public:
      SOMEIDTYPE();
      SOMEIDTYPE(const int&);
      SOMEIDTYPE& operator=(const SOMEIDTYPE&);
      operator int() const;
    private:
      int val_;
    };
    

    Now you can overload on SOMEIDTYPE

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following struct declaration and typedef in my code: struct blockHeaderStruct {
I have the following template declaration: template <typename T> void IterTable(int& rIdx, std::vector<double>& rVarVector,
I have a function with the following declaration: void cleanValid(int valid[][4], int &size, int
I have seen a web page source code containing the following css declaration at
I have following std::vector declaration: std::vector<std::vector<std::vector<int> > > m_input; I am initializing it as
I have the following HTMLHelper extension to create a submit button that would work
I have the following declaration. namespace test{ static cl_option* find_opt(const int &val, const cl_option
I have the following class declaration: class DEMData { private: int bitFldPos; int bytFldPos;
I have the following declaration in my code: u32 volatile __attribute__((nocast)) *A, *B; Is
In my c application I have the following declaration: typedef double mat[MAX_SIZE][MAX_SIZE]; I have

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.