Pure virtual function call
I wrote a program and tryied to run it. It immediately crashed and on my cerr output was: "Pure virtual method called". I just glared - how is it possible to call pure virtual function? I thought, that the linker must reject all bindings to virtual functions...?
Oxyd
---
- Unreadable code is code written on a piece of paper, but not the one, in which the programmer is using a space in the place you don''t.
- Real programmers aren''t afraid of goto
Likely your constructor is trying to call something pure virtual, or calls something which ends up calling something that''s pure virtual, which is only defined in a subclass. When the first constructor runs, the object isn''t really set up completely. The Vtable actually changes before running each constructor. If you manage to call a virtual function before the subclass constructor runs, it won''t be doing what you expect.
As far as I know, in constructors there''s no late binding. Just early binding - thus calling virtual function in constructor ends up with calling local version. And the linker should not link application where is binding (early) to pure virtual function...
Btw - debugging shows up that it occurs in delete call - thus it is probably in destructor in which (like in constructors) there''s only early binding.
Oxyd
---
- Unreadable code is code written on a piece of paper, but not the one, in which the programmer is using a space in the place you don''t.
- Real programmers aren''t afraid of goto
Btw - debugging shows up that it occurs in delete call - thus it is probably in destructor in which (like in constructors) there''s only early binding.
Oxyd
---
- Unreadable code is code written on a piece of paper, but not the one, in which the programmer is using a space in the place you don''t.
- Real programmers aren''t afraid of goto
I''ve had that error too, I think it was the result of some misuse of multiple inheritance. Check that all classes that need virtual inheritance are using it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement