2015-01-03 71 views
1

也许有人知道,是否有可能在本征中转发申报类型MatrixXd & VectorXd类型MatrixXd&VectorXd的前向声明?

在编译时,我得到以下错误:

/usr/include/eigen3/Eigen/src/Core/Matrix.h:372:34:错误:矛盾的声明“的typedef类征::矩阵Eigen :: MatrixXd'

typedef Matrix Matrix ## SizeSuffix ## TypeSuffix;

SIMP.h

#ifndef SIMP_H 
#define SIMP_H 


namespace Eigen 
{ 
    class MatrixXd; 
    class VectorXd; 
} 

class SIMP { 
public: 
    SIMP(Eigen::MatrixXd * gsm, Eigen::VectorXd * displ); 
    SIMP (const SIMP& other) = delete; 
    ~SIMP(){} 
    SIMP& operator= (const SIMP& other) = delete; 
    bool operator== (const SIMP& other) = delete; 


private:  
    Eigen::MatrixXd * m_gsm; 
    Eigen::VectorXd * m_displ; 

}; 

#endif // SIMP_H 

SIMP.cpp

#include "SIMP.h" 
#include <Eigen/Core> 
SIMP::SIMP(Eigen::MatrixXd * gsm, Eigen::VectorXd * displ) : 
    m_gsm(gsm), 
    m_displ(displ), 
{ 

} 

回答

2

不,你不能 “向前申报” 类型别名:既不MatrixXd也不VectorXdclass ES;他们是类型别名。

您可以通过编写typedef语句来尽早手动引入类型别名。这可能是一个坏主意。

顺便提一下,最后一行输出是高度可疑的;它看起来像一个宏定义,它肯定不会出现编译器错误。

+0

有一些自动typedefs设置显式模板=) –

+0

感谢您的回答! –