I have a strange problem here. Suppose I have a class with some virtual methods. Under certain circumstances, an instance of this class must call one of these methods. In most cases, there are no problems at this stage, but sometimes it turns out that the virtual method cannot be called because the pointer to this method is NULL (as shown in VS), therefore, an exception to the memory access violation occurs. How could this happen?
The application is quite large and complex, so I don’t know which low-level steps lead to this situation. Posting raw code will not be useful.
UPD: Well, I see that my presentation of the problem is rather vague, so the schematic code looks like
void MyClass::FirstMethod() const { }
void MyClass::SecondMethod() const
{
FirstMethod();
}
No constructors or destructors.
source
share