W
Wenjie
Hello,
I have a class B to mediate/isolate between
implementation and their users (like used in
an abstract factory class pattern):
// B.h
class B {
static B* getImpl();
static void update(B*& previous, B*& current);
};
// I.h
class I: public B {
static I* instance();
static void update(I*& previous, I*& current);
};
// B.cpp
B* B::getImpl()
{
return I::instance();
}
void B::update(B*& previous, B*& current)
{
return I::update((I*&)previous, (I*&)current);
}
I try to use static_cast<I*&>(previous) for (I*&) previous
but failed to compile for the above member function.
Do you think static_cast<I*>(previous) is OK for the cast?
Secondly, do you have a better pattern to achieve the
isolation as well as the task routing?
Thanks and best regards!
Wenjie
I have a class B to mediate/isolate between
implementation and their users (like used in
an abstract factory class pattern):
// B.h
class B {
static B* getImpl();
static void update(B*& previous, B*& current);
};
// I.h
class I: public B {
static I* instance();
static void update(I*& previous, I*& current);
};
// B.cpp
B* B::getImpl()
{
return I::instance();
}
void B::update(B*& previous, B*& current)
{
return I::update((I*&)previous, (I*&)current);
}
I try to use static_cast<I*&>(previous) for (I*&) previous
but failed to compile for the above member function.
Do you think static_cast<I*>(previous) is OK for the cast?
Secondly, do you have a better pattern to achieve the
isolation as well as the task routing?
Thanks and best regards!
Wenjie