R
ruud.bos
Hi list,
As a C++ newbie, I have a question about static member functions.
Suppose I have the following class definition:
class MyClass
{
public:
static void MyFunc();
};
static void MyClass::MyFunc()
{
// Do something useful here
}
Now I would like to enforce static usage of this function (i.e. if an
instance of this class is created, it should not be possible to use
MyFunc on that instance (might throw an exception), only
MyClass::MyFunc() should work)
Since static functions don't have access to the this prointer, I can't
check whether the function is invoked from an instance or as a static.
Does someone know a solution to this? Any help would be appreciated.
Cheers,
Ruud Bos
As a C++ newbie, I have a question about static member functions.
Suppose I have the following class definition:
class MyClass
{
public:
static void MyFunc();
};
static void MyClass::MyFunc()
{
// Do something useful here
}
Now I would like to enforce static usage of this function (i.e. if an
instance of this class is created, it should not be possible to use
MyFunc on that instance (might throw an exception), only
MyClass::MyFunc() should work)
Since static functions don't have access to the this prointer, I can't
check whether the function is invoked from an instance or as a static.
Does someone know a solution to this? Any help would be appreciated.
Cheers,
Ruud Bos