Thomas J. Gritzan wrote:
Manuel schrieb:
Victor Bazarov wrote:
Manuel wrote:
Victor Bazarov wrote:
Manuel wrote:
I need implement a map of member functions of some class.
This map is formed by a string and a pointer to the member
function.
Member of what class? What arguments does it take? What type
does it return?
The members are of different class that derive of a superclass and
this members do
not return anything.
What's the point to have member functions of different classes
stored in the same container? What's _common_ about those
functions? How do you intend to use those map elements?
And if they don't return anything, the return value type is 'void'.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
The methods are used to get objects. This methods have the same name
and the same parameters. it is like a constructor.
I have got a xml file that specifies the objects that i want with
his state
So the methods are static functions?
That's an information we need to help you. Give an example of such a
class/function (a minimal example).
You can typedef your function type and put pointers to that in the
map:
typedef void factory_t(baseclass&, const parameters&);
std::map< std::string, factory_t* > your_map;
--
Thomas
well Thomas, you give me an idea to solve the problem.
i can create a static method in the factory class for each one of the
classes and then in the map it save the pointer to this methods.
So, when I need a object i call to factory::(*pointer)(const
paramaters&)
something as well as this:
typedef float (*MyFuncPtrType)(const paramaters&);
map<std::string, MyFuncPtrType>;
map["method1"] = &method1;
map["method2"] = &method2;
when i need a object i call: factory::(*map["method1"])(parameters).
I think that this can work. what do you think?
If I may... This sounds OK, only to take address of a member function
And when you call it, you can't prepend it with 'factory::'. You just