Boost logo

Ublas :

Subject: Re: [ublas] define a matrix in my class
From: David Bellot (david.bellot_at_[hidden])
Date: 2010-02-01 13:10:09


you cannot declare and define at the same time your variable (at least in
C++, don't know for other languages)

What you can do is to add a constructor to your class and initialize qt
using the constructor like this:

class myclass
{
   public:
        myclass();
            ublas::identity_matrix<double> qt(3);
};

and then in your implementation
myclass::myclas() : qt(3)
{
 // some code if you need it
}

in what you do, C++ is confused with your (3) and doesn't know if it's
definition, declaration, code, or something else.
If you initaliaze qt in your constructor like I did, you will obtain the
expected result.

Cheers,
David

On Mon, Feb 1, 2010 at 19:00, Gianluigi Caddeo <ggigi78_at_[hidden]> wrote:

> hi
>
> I try to define a matrix in my class but
> I'have every time this problem:
>
> myclass.h:53: error: expected identifier before numeric constant
> myclass.h:53: error: expected ‘,’ or ‘...’ before numeric constant
>
> the code is like this:
>
> #include <boost/numeric/ublas/blas.hpp>
> #include <boost/numeric/ublas/matrix.hpp>
>
> namespace ublas = boost::numeric::ublas;
>
> class myclass {
>
> public:
>
> ublas::identity_matrix<double> qt(3);
>
> };
>
>
> where is the problem? please help me...
>
>
> thanks you
>
> gigi
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: david.bellot_at_[hidden]
>

-- 
David Bellot, PhD
david.bellot_at_[hidden]
http://david.bellot.free.fr