我的设计实施有问题。有一个超类定义方法,该方法具有该超类的子类作为返回值。正如你在这里看到的:
#ifndef I_ATTITUDEDESCRIPTOR_H
#define I_ATTITUDEDESCRIPTOR_H
#include "cl_EulerAngles.h"
#include "cl_Quaternion.h"
#include "cl_RodriguesParameters.h"
#include "cl_RotationMatrix.h"
#include "cl_TransformationMatrix.h"
class i_AttitudeDescriptor {
public:
i_AttitudeDescriptor();
virtual ~i_AttitudeDescriptor() = 0;
virtual cl_EulerAngles* getEulerAngles(cl_EulerAngles* result) = 0;
virtual cl_Quaternion* getQuaternion(cl_Quaternion* result) = 0;
virtual cl_RodriguesParameters* getRodriguesParameters(cl_RodriguesParameters* result) = 0;
virtual cl_RotationMatrix* getRotationMatrix(cl_RotationMatrix* result) = 0;
virtual cl_TransformationMatrix* getTransformationMatrix(cl_TransformationMatrix* result) = 0;
protected:
private:
};
#endif // I_ATTITUDEDESCRIPTOR_H
例如,其中一个子类由以下给出:
#ifndef CL_EULERANGLES_H
#define CL_EULERANGLES_H
#include "i_AttitudeDescriptor.h"
#include "cl_Quaternion.h"
#include "cl_RodriguesParameters.h"
#include "cl_RotationMatrix.h"
#include "cl_TransformationMatrix.h"
class cl_EulerAngles : public i_AttitudeDescriptor
{
public:
cl_EulerAngles();
~cl_EulerAngles();
cl_EulerAngles* getEulerAngles(cl_EulerAngles* result);
cl_Quaternion* getQuaternion(cl_Quaternion* result);
cl_RodriguesParameters* getRodriguesParameters(cl_RodriguesParameters* result);
cl_RotationMatrix* getRotationMatrix(cl_RotationMatrix* result);
cl_TransformationMatrix* getTransformationMatrix(cl_TransformationMatrix* result);
protected:
private:
};
#endif // CL_EULERANGLES_H
这些函数在 cl_EulerAngles.cpp 文件中实现。现在我遇到了问题,我得到了一个像这样的编译器错误:
i_AttitudeDescriptor.h|17|error C2143: syntax error : missing ';' before '*'|
i_AttitudeDescriptor.h|17|error C2433: 'i_AttitudeDescriptor::cl_EulerAngles': 'virtual' not permitted on data declarations|
i_AttitudeDescriptor.h|17|error C4430: missing type specifier - int assumed|
i_AttitudeDescriptor.h|17|error C2061: syntax error : identifier 'cl_EulerAngles'|
i_AttitudeDescriptor.h|17|error C4430: missing type specifier - int assumed|
i_AttitudeDescriptor.h|17|warning C4183: 'getEulerAngles': missing return type; assumed to be a member function returning 'int'|
i_AttitudeDescriptor.h|17|error C2253: "i_AttitudeDescriptor::getEulerAngles": pure specifier only applies to virtual function – specifier ignored|
||=== Build finished: 6 errors, 1 warnings (0 minutes, 0 seconds) ===|
我希望有人可以帮助我解决这个小问题。谢谢你。