Hello,

I've got a rudimentary CFC question.  Can you create class interfaces using
CFCs?  I suppose I'm looking for something akin to pure virtual methods in
C.  Here's an example of what I'm wanting to accomplish.  I know this is
incredibly contrived and the code is a hodgepodge of several different
languages...I'm just trying to get an idea across.  Thanks for your input!

Let's say I have a class:

class Vehicle {

  real forwardSpeed = 0; // MPH
  int numWheels = 0;
  char vehicleName = '';
 
  // public methods
  real Vehicle::go( real timeInHours ) { return forwardSpeed * timeInHours;
}
  void Vehicle::setName( char name ) { vehicleName = name; }
  char Vehicle::getName() { return vehicleName; }

  // interface methods
  void Vehicle::setForwardSpeed( int speed ) = 0;
  void Vehicle::setNumWheels( int wheels ) = 0;
}

class Car extends Vehicle {

  Car::Car() { super.setNumWheels(4); }

}

Now, in the code I want to create an instance of Car and Motorcycle.

obj1 = CreateObject( "component", "car" );
obj1.setForwardSpeed(50);
obj1.setName("Pinto");
obj2 = CreateObject( "component", "car" );
obj2.setForwardSpeed(120);
obj2.setName("Porsche");

if obj1.go(0.5) > obj2.go(0.5) {
  write( obj1.getName() );
else
  write( obj2.getName() );

write( " is the winner!" );


Ryan Hagan
ph: 540-731-3588
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to