> |
> |template<intdim>
> classA
> {
> public:
> A(std::vector<Point<dim>>&points);
> constKDTree<dim>&get_kdtree()const;
> doubledoing_something();
>
> private:
> KDTree<dim>kdtree;
> };
> |
> |
>
> and in my implementation i wrote
> |
> template<intdim>
> A<dim>::A(std::vector<Point<dim>>&points)
> {
> kdtree.set_points(points);
> }
>
> template<intdim>
> constKDTree<dim>&
> A<dim>::get_kdtree()const
> {
> returnkdtree;
> }
>
> template<intdim>
> double
> A<dim>::doing_something()
> {
> constauto&_v_kdtree =this->get_kdtree();
> ....
> }
>
> |
Thus looks right to me.
> But everytime i called the get_kdtree function, i got the segmentation fault(
> you may see the snippet in doing_something() function. Any idea to resolve
> this problem?
We just had another thread on the mailing list about segmentation faults and
how one debugs them. I don't think that your get_kdtree() function is wrong.
Something must be wrong in how you set up the object that contains it. You
will need to find out which pointer it is that creates the segmentation fault;
if you know this part, it is typically easy to understand what is happening.
My suspicion is that in your case, the 'this' pointer is a nullptr.
Best
W.
--
------------------------------------------------------------------------
Wolfgang Bangerth email:
bang...@colostate.edu
www:
http://www.math.colostate.edu/~bangerth/