code_junkie

Where do “pure virtual function call” crashes come from?

Nov 11th, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. int __cdecl _purecall(void)
  2.  
  3. int __cdecl _purecall(void)
  4.  
  5. class A
  6. {
  7. A *pThis;
  8. public:
  9. A()
  10. : pThis(this)
  11. {
  12. }
  13.  
  14. void callFoo()
  15. {
  16. pThis->foo(); // call through the pThis ptr which was initialized in the constructor
  17. }
  18.  
  19. virtual void foo() = 0;
  20. };
  21.  
  22. class B : public A
  23. {
  24. public:
  25. virtual void foo()
  26. {
  27. }
  28. };
  29.  
  30. B b();
  31. b.callFoo();
Add Comment
Please, Sign In to add comment