error C2352 static vs. non-static

Feb 21, 2012 at 11:03am

hello all,

i try to call a function from a commercial program, i have the following on my header file:

1
2
3
4
5
6
7
8
9
10
class MYPACKAGE_API MyComputeThreshold1 : public HxCompModule
{
    HX_HEADER(MyComputeThreshold1);  // required for all base classes

  public:

    virtual void compute();


};




then the following produces an error:

1
2
3
4
5
6
7
8
9
10
11
12
void MyComputeThreshold1::compute()
{	
#include <mclib/McDelaunay.h>

   McVec2f* Points = new McVec2f[ nPoints ];

// some code to get the coordinates

   McDArray<McDelaunay::Triangle> triangles;
   int dummy = McDelaunay::triangulate2D(Points, nPoints, triangles);

}





This gives:


1>.\MyComputeThreshold1.cpp(113) : error C2352: 'McDelaunay::triangulate2D' : illegal call of non-static member function



Now there is not much i dare to do to the header file this command is introduced, so how should i change my code to cope with this??


Thanks!
Feb 21, 2012 at 11:05am
1
2
McDArray<McDelaunay::Triangle> triangles;
int dummy = McDelaunay::triangulate2D(Points, nPoints, triangles);


This McDelaunay::triangulate2D(Points, nPoints, triangles); is an attempt to call a class function without actually going via an object of that class - you can't do this unless that function has been declared static. You have to call such a function via an instance of the class. Create an instance of the McDelaunay class and use that.
Last edited on Feb 21, 2012 at 11:08am
Feb 21, 2012 at 11:39am
You wouldn't normally include another file in the middle of a function.
Feb 21, 2012 at 3:47pm
Great!

That solved it!

Thanks!
Topic archived. No new replies allowed.