How can i get the address name of any variable/object?

Viewed 18

You know when you print an element's reference, you actually print the address's name that's related to the variable

int main()
{
int a=100;
std::cout<< &a;
return 0;
}
// 000GGHFGFDG...

I am trying to get that exact name, but i just couldn't find a way to take it nor from the "&a" or from the "*a" versions and get it into a string for later use.

I am trying to make a Hashmap template (template <class A,classB> class Hashmap {...}; ) and i came up with the idea of getting the address name of the key and convert it into an string so i can calculate the index where i need to store it within this data structure.

I even tried to get the name of the address itself with the "typeid(std::ref(a)).name()" from typeinfo library (and actually tried to convert it into an string hoping it would work) ,but it just doesn't.

Does anyone here know how to get that address name and use in code and not only for printing?

0 Answers
Related