[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] gsl_vector memory management help

From: Francesco Abbate
Subject: Re: [Help-gsl] gsl_vector memory management help
Date: Thu, 29 Jul 2010 22:13:54 +0200

2010/7/29 Peter Johansson <address@hidden>:
> The problem is that you have not implemented any copy constructor, which
> means you're using the compiler generated version that just copies all
> members. You need to implement a copy constructor that creates a new
> gsl_vector. Something like this IIRC:
> myMember_t::myMember_t(const myMember_t other)
> {
>  v = gsl_vector_alloc(DIM);
>  gsl_vector_memcpy(v, other.v);
> }

Just a precision, in the copy constructor the argument should be
passed as a reference:

myMember_t::myMember_t(const myMember_t& other)
  v = gsl_vector_alloc(DIM);
  gsl_vector_memcpy(v, other.v);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]