0

I want to create a matrix with the boost library, and then include it in a struct. This matrix will be then transformed in a function. The problem is that I'm not able to create an element of the struct from the boost library:

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    }

When I build, an error appears in line 20:

statement cannot resolve address of overloaded function

Anyone knows how to introduce this element from boost library into the struct? Thanks for your help

santimiq
  • 13
  • 5
  • You are declaring a member function here: `matrix s();`, try removing the parentheses. We should look for a suitable duplicate here... – lubgr Jul 01 '19 at 11:01

1 Answers1

2

Change this line:

12    matrix<double > s();

To

12    matrix<double > s{};

or simply:

12    matrix<double > s;

The first declaration is function, which is causing the error (since you didn't implement that function)

darune
  • 10,480
  • 2
  • 24
  • 62
  • Thank you very much, I used the third option, but could you please tell me the difference between the second and the third? I would really appreciate – santimiq Jul 01 '19 at 11:09
  • The brace-init is safer - it makes sure the object gets initialized (however in practice theres no difference in this situation) – darune Jul 01 '19 at 11:12