0

I created a map<string, void*>.
The void* used to store an Object from a class called Window.

I can cout a string with the following:

it = windowMap.find(title);
	if( it != windowMap.end() ) 
	{
		cout << "Value is: " << it->first << '\n';
	} else {
		cout << "Key nog found" << '\n';
	}

So i can cout the string, but what i want to do is use the void*.
I figured that i have to use it->second, but i use functions of the class window.

it->second->getTitle();

Will of course not work.
How do I do that then?

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Oritm
0

try it as follows

Window *w=(Window *)it->second;
/*or (Window *)(it->second)      if the former gives error*/
w->getTitle();
0

Thanks, works like a charm!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.