View Full Version : rtti() of derived class
quickNitin
8th October 2006, 12:12
Here is small pbm i am facing.
I have deriver a MyCanvasItem class from Q3CanvasPolygonal class.
i have overridded rtti() to return specific value.
But it clicking on this MyCanvasItem is return 2i.e. Q3CanvasPolygonal::RTTI.
where i can improve upon.
quickNitin
jpn
8th October 2006, 12:28
Is it declared virtual in the base class (Q3CanvasPolygonal)? Does the signature of the function match exactly (including constness)?
quickNitin
8th October 2006, 13:12
ya there was some difference. Now it works
in Q3CanavsPolygonal class it is defined as
virtual int rtti() const{}
but i declared it as member
virtual const int rtti() {}. How this declaration is diffrent from above? I am not awar of difference. It has become now C++ doubt.
now i had declare rtti() very same as in parent class and now it is working.
thanks jpn
jacek
8th October 2006, 13:27
in Q3CanavsPolygonal class it is defined as
virtual int rtti() const{}
but i declared it as member
virtual const int rtti() {}. How this declaration is diffrent from above?
First one is a "const" (i.e. non-mutating) method that returns an integer, while second one is a normal method that returns a constant integer.
In short: "const" methods can't change member variables and therefore they can be invoked on constant objects.
http://www.parashift.com/c++-faq-lite/const-correctness.html
quickNitin
8th October 2006, 14:20
thanks jacek
its working well now!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.