I'm facing an Illegal Access error, but I'm not sure whats happening in my code...
I have a class like this:
class MyClass
{
cHapticDeviceHandler* handler;
public:
MyClass(void){handler = new cHapticDeviceHandler();}
~MyClass(void){delete handler;}
cHapticDeviceHandler* getHandler() {return handler;}
};
If I create a function like this my code just works. I can create a new object and use that getHandler() method to use the cHapticDeviceHandler* without problems.
function A(){
MyClass* obj1 = new MyClass();
...
}
However, if I try doing something like this...
function B(){
MyClass* obj1 = new MyClass();
MyClass* obj2 = new MyClass();
}
The first obj1 is created without problems, but the second one just crash with an Illegal Access error while executing the constructor.
If I'm not wrong, when you create new objects from a class, their attributes are different so each object has his own attributes. With this in mind, I pressume that those cHapticDeviceHandler pointers are different in the two objects, so I can't understand why doing a new in the first place works, and doing it again just won't work.
I'm pretty sure I'm doing something really wrong and embarrasing buuuut... I can't find where is the problem :$
Could anyone give me a hint please? I'm forced to use Visual Studio 2008 and I'm using CHAI3D, just in case that's important.