Quick Question about Static variables inside function calls in MC++ [modified]
-
First off - a bit of background: For a project i'm working on I need to distribute objects to groups of users based on a number of different algorithms, my idea was to store the state for each algorithm inside their respective functions using static variables. This was to be done in C# until I realised C# doesn't support this functionality but i know C++ does. Sooo ... Does Managed C++ support static variables inside functions in the same way as standard C++ does or is it a limitation of the CLR that means this functionality isn't available in .NET? Thanks Richard
Richard Green
modified on Thursday, January 24, 2008 7:43:20 AM
-
First off - a bit of background: For a project i'm working on I need to distribute objects to groups of users based on a number of different algorithms, my idea was to store the state for each algorithm inside their respective functions using static variables. This was to be done in C# until I realised C# doesn't support this functionality but i know C++ does. Sooo ... Does Managed C++ support static variables inside functions in the same way as standard C++ does or is it a limitation of the CLR that means this functionality isn't available in .NET? Thanks Richard
Richard Green
modified on Thursday, January 24, 2008 7:43:20 AM
Never mind, I refactored my code so each algorithm is inside its own class and can now use static class members to store current state. Richard
Richard Green
-
Never mind, I refactored my code so each algorithm is inside its own class and can now use static class members to store current state. Richard
Richard Green
That is the right way to do it, whatever language you choose. State belongs to an object, not to a function. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
That is the right way to do it, whatever language you choose. State belongs to an object, not to a function. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
Yeah, it was just one of those mornings eariler - took a 5min break came back and realised I was going about it backwards :)
Richard Green