TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Steven Pasztor
from: Frank Adam
date: 1996-12-02 15:24:00
subject: classes

G'Day Steven,
 
-=> Quoting Steven Pasztor to Frank Adam <=-

 SP> If bozo() is a virtual method in baseclass, any way to 
 SP> call it from a function which takes a derived as its parameter?  
As long as the derived is in scope, the base is accesible.
 
 SP> And more interestingly, any way to pass a 
 SP> dervived to a function that expects a baseclass?
Short answer is, i don't think so.:-)
I don't think your base class knows about it's derived classes. 
Another one to test and see, but i guess it won't work.

 SP> eg. Imagine a game, where the NPC's are handled by objects.  They all
 SP> have  the same mathods, and call the same methods of other 
 SP> objects, but some or all of their internals are different.  
 SP> Sometimes it's possible to re-use the standard code, 
 SP> othertimes entirely new routines must be written.  But 
 SP> always, the rest of the program doesn't want to know which 
 SP> NPC object it's dealing with, because there's simply too 
 SP> many to handle each one differently.  So it just wants an 
 SP> NPC object, which handles itself appropriately.
I don't see the problem, even with OOPs you have to tell the functions what 
variables to use and for what. If you send a NPC object to func a()
and a()'s job is to only move the NPC x pixels in direction d, it won't 
care about the other variables within the NPC except for the sprite 
pointer and the xy position.
                           
  L8r Frank (fadam{at}ozemail.com.au).

                             
___ Blue Wave/DOS v2.21

---
* Origin: Melbourne PC User Group BBS (3:632/309)
SEEN-BY: 633/267 270
@PATH: 632/309 107 360 50/99 635/728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.