I'm working on a DLL project, I'm writing a class with variables and functions in a header and the definitions in a .cpp file like this:
.h:
#ifndef RE_MATH_H
#define RE_MATH_H
#ifdef MATHFUNCSDLL_EXPORTS
#define RE_MATH_API __declspec(dllimport)
#else
#define RE_MATH_API __declspec(dllexport)
#endif
#define PI 3.14159265358979323846
namespace RE_Math
{
class RE_MATH_API Point
{
public:
double X;
double Y;
double Z;
float alpha;
Point(double x, double y, double z, float a);
static void getPoint(double x, double y, double z, float a);
};
}
and the .cpp:
#include <re_math.h>
namespace RE_Math
{
Point::Point(double x, double y, double z, float a)
{
X = x;
Y = y;
Z = z;
alpha = a;
}
void Point::getPoint(double x, double y, double z, float a)
{
x = X;
y = Y;
z = Z;
a = alpha;
}
}
OK, so in the constructor I have no problems, but in the getPoint()
function I get the "non-static member reference must be relative to specific object" error and it won't let me use the variables. I tried making the variables static, but that gives me unresolved external symbol errors in the same places, in getPoint().
What should I do to fix this?