Re: Mix Static and dynamic Polymorphism
{ Please avoid top-posting, and don't quote the clc++m banner. -mod }
Hello all,
I just reach a solution that simply regard interface::execute as a
wrapped member function,
name it different from PolicyA::execute and wrap it inside:
struct Interface{
virtual void run() = 0;
virtual void executeInterface() = 0;
}
template <class Policy>
struct Base : public Policy, public Interface{
using Policy::execute;
void run(){
// implementing base ;
}
void executeInterface(){
execute();
}
}
This solution is just a little bit "ugly", could someone find a
solution
that compose the Interface class ? Thank you in advance.
Jun
On Nov 7, 11:16 am, Jun <junh...@gmail.com> wrote:
Hello all,
I just tried to mix static and dynamic polymorphism together.
I've a vector to store all the elements, and the implementations
of elements are slightly different. I used Policy-based design:
struct Interface{
virtual void run(void) = 0;
virtual void execute(void) = 0;
};
struct PolicyA{
void execute(){
// implementing Policy A;
}
};
struct PolicyB{
void execute(){
// implementing Policy B;
}
};
template <class Policy>
struct Base : public Policy, public Interface{
void run(){
// implementing base ;
}
}
Anyway, those codes don't compile .... Anyone has some suggestions ?
Thank you in advance.
Jun
--
[ Seehttp://www.gotw.ca/resources/clcm.htmfor info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]