Pure Virtual Function Called
I’ve been chasing this bug for the last few days. The program compiles fine, no complaints. It runs fine up until you call a certain method at a certain time, then the program dies and you get “Pure Virtual Function Called” printed out to standard error. What can you do?
Well for me the problem was in the constructor of one of the classes I had written. It would take in parameters to the constructor and assign them to be class attributes like so:
Simple::Simple(iObject* obj) : object(obj) { }
So it would set the attribute object to be equal to obj. This compiles fine but was the reason that the pure virtual function called error was appearing. By changing the constructor to:
Simple::Simple(iObject*obj) { object = obj; }
the error amazingly disappeared. Joy, it only took 2 days to track down. Now I can get on with worrying about the implementation rather than chasing down stupid C++ and CrystalSpace bugs.
About this entry
You’re currently reading “Pure Virtual Function Called,” an entry on The Moon is Down
- Published:
- 05.01.07 / 2pm
- Category:
- Work, Programming, Computers
No comments
Jump to comment form | comments rss [?] | trackback uri [?]