GIDForums  

Go Back   GIDForums > Computer Programming Forums > FLTK Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 15-Dec-2004, 10:09
achoo achoo is offline
New Member
 
Join Date: Dec 2004
Posts: 1
achoo is on a distinguished road
Question

calling abstract base class method calls draw instead


hello 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  
Old 19-Dec-2004, 09:38
fltk2user fltk2user is offline
New Member
 
Join Date: Dec 2004
Posts: 5
fltk2user is on a distinguished road
Quote:
Originally Posted by achoo
hello 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!

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 GIDBlogToyota - 2008 September Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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

All times are GMT -6. The time now is 05:28.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.