Victor Bazarov wrote:
Quote:
If I may... This sounds OK, only to take address of a member function
you need the class before the name:
>
map["method1"] = &OneClass::method1;
map["method2"] = &TwoClass::method2;
>
And when you call it, you can't prepend it with 'factory::'. You just
use
>
map["method1"](parameters);
>
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Of course, you may.
well. I think that this is not neccesary because in the end the methods
will be of the same class.
i make this:
FACTORY_H
typedef void (*PtrMethod)(std::vector<std::string>);
class Factory
{
private:
map<const char*, PtrMethod*, ltstrtheMap;
protected:
Factory();
~Factory();
Object * method1(std::vector<std::string>);
Object * method2(std::vector<std::string>);
public:
Object *
getObject(std::string,std::vector<std::string>);
};
FACTORY_CPP
Factory::Factory()
{
map["method1"] = &method1;
map["method2"] = &method2;
}
Object * Factory::getObject(string label,vector<stringparamaters)
{
PtrMethod method = theMap[label];
Object * object = (*method)(parameters);
return energia;
}
is it correct? what do you think?
thank you very much by your attention