0

Hey I'm trying to set a Strategy in my program that should allow me to do something I've never tried before and have no idea if it's either the best approach to the problem or if it is possible or not.


I have a class with some fields and one of them is a String function and I want to check the value of that function (in this case will just be the name of the function) and then find a method with the same name in my class.

How can I do that?

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by arkoenig
0

You can't do it directly, and it's hard to understand why you would want to so--because if you could, the behavior of your program would depend on the names you choose for its components.

0

How could I do it indirectly?
I just want to know how to verify all the methods used in my class and see if one of them matches with the function I have.

I apreciate all the hints to set the best strategy to this.

0

You might use a map, with the strings you care about as keys and pointers to the relevant functions as values.

Either that or use an enum type as the value, with one member for each function you care about.

This topic has been dead for over six months. 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.