Example:
#include<iostream>
using namespace std;
enum e_UserName
{
planet1,
planet2,
planet3,
planet4,
planet5,
planet6,
planet7
};
enum e_ServerName1
{
Venus = 11,
Mars,
earth
};
enum e_ServerName2
{
jupiter = 11,
pluto,
neptune,
earth2
};
struct map
{
enum e_UserName eUserName;
enum e_ServerName eServerName;
};
struct map name[] = { {planet1,(e_ServerName) Venus},
{planet2, (e_ServerName)Mars},
{planet3, (e_ServerName)earth},
{planet4, (e_ServerName)jupiter},
{planet5, (e_ServerName)pluto},
{planet6, (e_ServerName)neptune},
{planet7, (e_ServerName)earth2}
};
int main()
{
for(int i=0; i<7; i++)
{
cout<<name[i].eUserName<<"is = "<<name[i].eServerName<<endl;
}
for(int i=0; i<3; i++)
{
if (name[i].eUserName == planet2)
{
cout<<"Server Name = "<<name[i].eServerName<<endl;
break;
}
}
return 0;
}
Now I will go with the requirement as follows;
There is one enum "e_UserName" at one end having values b/n 0 -to- 6.
At the other and we have two different enums "e_ServerName2" (0 - 2) and "e_ServerName1" (0 - 3).
Now and i need to map below two eums with the above enum "e_UserName".
Secondly,
I will get the values of "e_ServerName2" (0 - 2) and "e_ServerName1" (0 - 3) as INPUT to my Function() and
I need to Return the respective enum "e_UserName" values from that function.
Could you please let me know how can i do this (logic).
Also if any Features in C++ that can support this requirement is also OK. (C++ Libraries using MAP or other).
Thanks well in Adwance
`**