c++ - 变量类型不完整的编译器错误

标签 c++ boost namespaces compiler-errors

启动错误,通过构建以下代码来显示该错误:
Testfile.cpp:27:41: error: variable ‘boost::numeric::ublas::matrix_column<boost::numeric::ublas::bounded_matrix<double, 2u, 2u> > op1’ has initialiser but incomplete type.
请考虑以下代码:

//! System includes
#include <iostream>
#include <fstream>
//! Boost includes
#include <boost/lexical_cast.hpp>
#include <boost/integer/static_min_max.hpp>

#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/array.hpp>

int main( )
{
    namespace ublas = boost::numeric::ublas;

    typedef ublas::bounded_matrix<double,2,2>       MatDofDdim;
    typedef ublas::bounded_vector<double,2>             VecDof;

    MatDofDdim op;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            op(i,j)=i+j;
        }
    }

    //VecDof op1;
    ublas::matrix_column<MatDofDdim> op1 ( op, 1 ) ;

    //VecDof op1( ublas::matrix_column<MatDofDdim>( op, 1 ));
    return 0;
}

我还尝试了另一种方法,在"ublas::matrix_column<MatDofDdim> op1 ( op, 1 ) ;"行中添加了注释,在前一行和后一行中取消了注释。

然后它说:Testfile.cpp:29:48: error: redeclaration of ‘VecDof op1’ Testfile.cpp:26:9: error: ‘VecDof op1’ previously declared here Testfile.cpp:29:54: error: invalid use of incomplete type ‘struct boost::numeric::ublas::matrix_column<boost::numeric::ublas::bounded_matrix<double, 2u, 2u> >’ /usr/include/boost/numeric/ublas/fwd.hpp:75:11: error: declaration of ‘struct boost::numeric::ublas::matrix_column<boost::numeric::ublas::bounded_matrix<double, 2u, 2u> >’
我在ubuntug++中使用eclipse。

最佳答案

matrix_column<boost/numeric/ublas/matrix_proxy.hpp>中声明
http://www.boost.org/doc/libs/1_51_0/libs/numeric/ublas/doc/matrix_proxy.htm#matrix_column

关于c++ - 变量类型不完整的编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12410860/

相关文章:

c++ - if 字符串验证循环的问题

c++ - 如何独立使用 Boost.Filesystem?

javascript - typescript - 未定义命名空间问题

c++ - 模板特化结构大小

c++ - 当对象被删除时,引用会发生什么?

c++ - std::copy_exception 在哪里定义?

c++ - Boost.Log 与 Boost.Log v2

c++ - 使用 boost::mpl::bitor_

ruby-on-rails - Rails 3 命名空间和自定义类的问题(未初始化常量)

c# - 使用多个命名空间来描述一个类