Enum as a type for function?

This code

1
2
3
4
5
6
7
8
9
10
enum  MenuResult
	{
		Nothing, // Enums for game state
		Exit,   // Enums for game state
		Play,   // Enums for game state
	};



	MenuResult Show(sf::RenderWindow& window)


Im not really sure why the Show has a parameter. I mean its an enum.

Doesnt that suppose to be

MenuResult Show = MenuResult.Nothing; ?

Why does the show has a parameter? It just doesnt make any sense. I tried searching it on google and I cant seem to find this kind of application of enum.

Can some explain me why is this? I dont see the connection of the parameter to the enum MenuResult
Last edited on
Show is a function. It takes an argument of type sf::RenderWindow& and returns a value of type MenuResult.

In other words, the value the function returns can either be Nothing, Exit or Play.
Last edited on
Show is a function, taking reference to RenderWindow as a parameter (most likely a window to show) and returning a MenuResult value (no idea what for).

Edit: ninja'd
Last edited on
Coming from c# this is kinda weird to look at really.

SO in other words the parameter sf::RenderWindow window has nothing to do with the return type itself? It just takes the parameter and do something about it and just return an enum?


Its really weird. First time seeing this kind of enum application.
SO in other words the parameter sf::RenderWindow window has nothing to do with the return type itself? It just takes the parameter and do something about it and just return an enum?

Yes, that's correct. That function declaration has exactly the same syntax as any other function declaration:

return_type function_name(parameter definitions);
Last edited on
Coming from c# this is kinda weird to look at really.
Its really weird. First time seeing this kind of enum application.

You can do the same in C#
http://ideone.com/IpnDCA
I see.. Thanks everyone.


also on the c#. Awesome work. Thanks.

I also didnt know that you can do this on enum even on c#. I have so much more to learn

Thanks everyone
Last edited on
Topic archived. No new replies allowed.