S
Steven T. Hatton
This is a question about coding styles. I've seen some cases where the
programmer has redeclared the pure virtual functions from an interface
class in the implementation derived from it. For example, I have this
abstract base class:
namespace widgets {
template<Var_T=float>
class VFunctor_IF {
public:
virtual void operator()(const std::vector<Var_T>& vars_ptr) = 0;
};
}
I'm deriving this implementation from VFunctor_IF:
//header file
class RotationFunctor: public VFunctor_IF<float> {
public:
// To declare or not to declare?
virtual void operator()(const std::vector<float>& vars_ptr);
private:
osg::ref_ptr<osg:
ositionAttitudeTransform*> _pat_ptr;
};
//source file
void RotationFunctor:
perator()(const std::vector<Var_T>& vars) {
using namespace osg;
Matrix m = Matrix::rotate(vars[0], X_AXIS) * Matrix::rotate(vars[1],
Y_AXIS) * Matrix::rotate(vars[2], Z_AXIS);
Quat q;
q.set(m);
_pat_rptr->setAttitude(q);
}
Clearly, I have to implement the pure virtual VFunctor_IF:
perator() in the
the derived class. My question is whether I should declare it in the class
definition of RotationFunctor.
Any opinions on this?
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell
programmer has redeclared the pure virtual functions from an interface
class in the implementation derived from it. For example, I have this
abstract base class:
namespace widgets {
template<Var_T=float>
class VFunctor_IF {
public:
virtual void operator()(const std::vector<Var_T>& vars_ptr) = 0;
};
}
I'm deriving this implementation from VFunctor_IF:
//header file
class RotationFunctor: public VFunctor_IF<float> {
public:
// To declare or not to declare?
virtual void operator()(const std::vector<float>& vars_ptr);
private:
osg::ref_ptr<osg:
};
//source file
void RotationFunctor:
using namespace osg;
Matrix m = Matrix::rotate(vars[0], X_AXIS) * Matrix::rotate(vars[1],
Y_AXIS) * Matrix::rotate(vars[2], Z_AXIS);
Quat q;
q.set(m);
_pat_rptr->setAttitude(q);
}
Clearly, I have to implement the pure virtual VFunctor_IF:
the derived class. My question is whether I should declare it in the class
definition of RotationFunctor.
Any opinions on this?
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell