boost库中的矩阵如何在结构中使用?

时间:2019-07-01 10:59:59

标签: c++ matrix boost struct

我想用boost库创建一个矩阵,然后将其包含在结构中。然后将这个矩阵转换为一个函数。问题是我无法从boost库中创建结构的元素:

1    #include <stdio.h>
2    #include <stdlib.h>
3    #include <iostream>
4    #include <math.h>
5    #include <boost/numeric/ublas/matrix.hpp>
6    #include <boost/numeric/ublas/io.hpp>
7     using namespace std;
8     using namespace boost::numeric::ublas;
9    
10    struct grupo
11      {
12    matrix<double > s();
13       int a;
14      };
15 
16    int main(void) {
17             
18         grupo Prueba;
19         Prueba.a;
20         Prueba.s;
21    
22    }

构建时,第20行出现错误:

声明无法解析重载函数的地址

任何人都知道如何将Boost库中的此元素引入结构中吗?谢谢您的帮助

1 个答案:

答案 0 :(得分:2)

更改此行:

12    matrix<double > s();

收件人

12    matrix<double > s{};

或简单地:

12    matrix<double > s;

第一个声明是函数,这会导致错误(因为您没有实现该函数)