Original Post
Hi there I am trying to create singleton class that will handle interface of my module with the programmer.The trick is that I want it to dynamically bind best posisible functionc to it's methods declarations. Currently I have almost done it but mu function's don't have access to class protected variables.
This is my current code example:
But during compilation I get this error :
It refers to bodies of pointSizeMin_gl20 and pointSizeMin_gl30.
So how to allow these functions to work with private/protected data? Is there any way at all?
Thanks,
MrKaktus
This is my current code example:
typedef float(*PFNENRCPOINTSIZEMINPROC)(void); // Func ptr typedef
float pointSizeMin_gl20();
float pointSizeMin_gl30();
PFNENRCPOINTSIZEMINPROC enGpuPointSizeMin = NULL;
class layout
{
protected:
static float var;
public:
layout();
float pointSizeMin(void);
friend PFNENRCPOINTSIZEMINPROC;
};
float layout::var;
layout::layout()
{
var = 1.0f;
enGpuPointSizeMin = pointSizeMin_gl30;
}
float layout::pointSizeMin(void)
{
return enGpuPointSizeMin();
}
float pointSizeMin_gl20(void)
{
return 2.0f + layout::var;
}
float pointSizeMin_gl30(void)
{
return 3.0f + layout::var;
}
int main(int argc, char* argv[])
{
layout renderer;
float result = renderer.pointSizeMin();
return 0;
}
But during compilation I get this error :
1>src\main.cpp(48): error C2248: 'layout::var' : cannot access protected member declared in class 'layout'
1> src\main.cpp(19) : see declaration of 'layout::var'
1> src\main.cpp(17) : see declaration of 'layout'
It refers to bodies of pointSizeMin_gl20 and pointSizeMin_gl30.
So how to allow these functions to work with private/protected data? Is there any way at all?
Thanks,
MrKaktus