doc: Add constructor to example for inheritance.

See "Error in Inheriting Eigen::Vector3d" on forum.
(transplanted from b582b2ebdc5657c993698e89db699e885af68c55
)
This commit is contained in:
Jitse Niesen 2012-07-05 13:36:02 +01:00
parent dee3325ef5
commit 4a7609fa74

View File

@ -83,7 +83,7 @@ An example of when you actually need to inherit Matrix, is when you have
several layers of heritage such as MyVerySpecificVector1,MyVerySpecificVector1 -> MyVector1 -> Matrix and.
MyVerySpecificVector3,MyVerySpecificVector4 -> MyVector2 -> Matrix.
In order for your object to work within the Eigen framework, you need to
In order for your object to work within the %Eigen framework, you need to
define a few members in your inherited class.
Here is a minimalistic example:\n
@ -93,8 +93,15 @@ class MyVectorType : public Eigen::VectorXd
public:
MyVectorType(void):Eigen::VectorXd() {}
// You need to define this for your object to work
typedef Eigen::VectorXd Base;
// This constructor allows you to construct MyVectorType from Eigen expressions
template<typename OtherDerived>
Vector3D(const Eigen::MatrixBase<OtherDerived>& other)
: Eigen::Vector3d(other)
{ }
// This method allows you to assign Eigen expressions to MyVectorType
template<typename OtherDerived>
MyVectorType & operator= (const Eigen::MatrixBase <OtherDerived>& other)
{