Hi Noel,
On 7/26/10 7:39 PM, Noel du Toit wrote:
I am pretty new to C++, but as far as I can tell the memory allocation is
correct, so I think it is my lack of understanding of the memory management on
gsl_vector side that is causing this (hence the email to this list). Any help
will be appreciated. Attached is the source code that I use, with the compile
command at the top of the file.
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);
}
A good rule is that when you implement the destructor, you likely need
to implement the copy constructor as well.
Cheers,
Peter
_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl