Sunday, July 12, 2009

A bit of C++ help?

virtual void draw() const = 0;





Does anyone know what "const = 0" means? I've seen just "const" before but what is the = 0 for?





Thanks!

A bit of C++ help?
I think the = 0 means the method is being defined as a pure virtual that must be overridden in any derived classes. The const before it flags something else to the compiler and isn't really related to the = 0.





Hope that helps.
Reply:it means an overridden draw() should also have the signature 'void draw()'.





Look at http://tydbits.com/blog/pavel/entry/brea... A full discussion seems to have happened on this bit.
Reply:take a look at it again


it's probably a typo
Reply:Are you sure it wasn't a typo? I'd look at it again
Reply:it means that the value default for const variables'll b 0. .


jj


No comments:

Post a Comment