Reputation: 4191
vector <unordered_map <string, DomainInfo *> *> victimDomains;
What does this mean?
I got the first star (DomainInfo*
) but what is the second one?
Lets say DomainInfo
has two properties ID
and name
. If I want to bring the second element in DomainInfo
of third unordered_map
in victimDomains
how could I call it?
is my question not correct?
Thanks,
Upvotes: 0
Views: 109
Reputation: 31952
In plain english, it is a vector
of pointers to (unordered_map
s mapping string
s to pointers of DomainInfo
). (using brackets to indicate levels)
You want to do
(*victimDomains[2])[<domainInfoKey>]->name;
^B ^A ^C ^D
A - 2nd Element - a pointer to the map.
B - Dereference the pointer to the map to get a map.
C - Get the DomainInfo
pointer (need to enter the correct string)
D - Use -> syntax to access the name field from the DomainInfo
pointer.
Above in multiple steps -
unordered_map <string, DomainInfo *> *map = victimDomains[2];
DomainInfo *dmInfo = *map[<domainInfoKey>];
Name name = dmInfo->name;
Upvotes: 6
Reputation: 171127
To access a particular DomainInfo
, you need to know its key in the unoreder_map
. So exactly as it stands, your question (how to access?) cannot be answered. However, if you knew the DomainInfo
's key was, let's say, "blah"
, then you would do:
(*victimDomains[2])["blah"]->name
Upvotes: 1