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.
A
typedefonly 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:Now you can overload on
SOMEIDTYPE