![]() |
|
#1
|
|||
|
|||
calling abstract base class method calls draw insteadhello all,
I am wondering why a call to a method declared in one abstract base class and implemented in another class results in a call to draw() instead of the method I'm talking about. Details below: I have an abstract base class called DrawingSurface. It has a method DrawingSurface::draw_rectangle() I also have a class called ImplementsDrawingSurface which inherits from DrawingSurface and has an implementation of draw_rectangle() I have a third class Client which expects to be handed something that implements DrawingSurface. It tells that object to draw_rectangle(). In my code, I hand Client pointer to an instance of ImplementsDrawingSurface (cast as DrawingSurface*). In the debugger, when I step into Client's call to DrawingSurface::draw_rectangle() it takes me to ImplementsDrawingSurface:: draw() instead. Why? note: I am using FLTK 1.1.4 note: so far there are no uses of fl::lock() and fl::unlock() in my code. Should there be? Is this a threading/synchronization problem? note: This problem causes an infinite loop in my code because ImplementsDrawingSurface::draw() tells its children to draw themselves and hand them a pointer to itself, cast as DrawingSurface. These in turn use the pointer to draw rectangles. Unfortunately, rectangles aren't drawn. Instead ImplementsDrawingSurface::draw() is called! note: I am using the abstract base class DrawingSurface because ImplementsDrawingSurface is in a different library from Client and our architecture/dependency-diagram doesn't allow Client to know about classes in ImplementsDrawingSurface's library. Thanks in advance! |
|
#2
|
|||
|
|||
|
Quote:
Most likely this is C++ coding mistake, not fltk.. But you never know. Could you make as small as possible code example that produces this bug? So I (other ppl's also) can try it out, and try to solve bug. |
Recent GIDBlog
Toyota - 2008 September Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Introduction to .NET | LuciWiz | .NET Forum | 5 | 09-Aug-2007 04:53 |
| Error C2146: syntax error : missing ',' before identifier 'C4' | mattchew008 | C++ Forum | 2 | 19-Dec-2004 06:06 |
| Help! Some basal questions about MFC | xutingnjupt | MS Visual C++ / MFC Forum | 1 | 05-Dec-2004 03:38 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The