Iva*_*ush 6 c++ forward-declaration eigen
也许有人知道,是否可以在特征中转发声明类型MatrixXd & VectorXd?
\n\n编译时,我收到以下错误:
\n\n/usr/include/eigen3/Eigen/src/Core/Matrix.h:372:34: 错误:声明冲突 \xe2\x80\x98typedef 类 Eigen::Matrix Eigen::MatrixXd\xe2\x80\x99
\n\ntypedef Matrix Matrix##SizeSuffix##TypeSuffix;
\n\nSIMP.h
\n\n#ifndef SIMP_H\n#define SIMP_H\n\n\nnamespace Eigen\n{\n class MatrixXd;\n class VectorXd;\n}\n\nclass SIMP {\npublic:\n SIMP(Eigen::MatrixXd * gsm, Eigen::VectorXd * displ);\n SIMP ( const SIMP& other ) = delete;\n ~SIMP(){}\n SIMP& operator= ( const SIMP& other ) = delete;\n bool operator== ( const SIMP& other ) = delete;\n\n\nprivate: \n Eigen::MatrixXd * m_gsm;\n Eigen::VectorXd * m_displ;\n\n};\n\n#endif // SIMP_H\nRun Code Online (Sandbox Code Playgroud)\n\nSIMP.cpp
\n\n#include "SIMP.h"\n#include <Eigen/Core>\nSIMP::SIMP( Eigen::MatrixXd * gsm, Eigen::VectorXd * displ) :\n m_gsm(gsm),\n m_displ(displ), \n{\n\n}\nRun Code Online (Sandbox Code Playgroud)\n
不,你不能“转发声明”类型别名:esMatrixXd也不VectorXd是;class它们是类型别名。
您能做的最好的事情就是通过写出typedef语句来手动引入类型别名。这可能是一个坏主意。
顺便说一句,最后一行输出非常可疑;它看起来像一个宏定义,绝对不应该出现在编译器错误中。