Announcement

Collapse
No announcement yet.

Class Methods Versus Interface Methods

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Theo Gottwald
    replied
    Means, if we would do the same with all state employee's (keep them in a CLOSED CLASS - nobody can touch them) corruption would have an end :-).

    Leave a comment:


  • Bob Zale
    replied
    A CLASS METHOD is private. It may not be called from outside the CLASS.

    Bob Zale
    PowerBASIC Inc.

    Leave a comment:


  • Ken Myers
    started a topic Class Methods Versus Interface Methods

    Class Methods Versus Interface Methods

    So I was looking at the example provided here:

    http://www.powerbasic.com/support/pb...ad.php?t=38248

    And I decided to experiment a little with the Sheep class doing the following:

    Code:
    CLASS Sheep
    
      CLASS METHOD SheepGroom() AS STRING
        METHOD="You Shear The Sheep."
      END METHOD
    
      INTERFACE ISheep : INHERIT Animal, IAnimal                'Note that in this 'Sheep' class we
        OVERRIDE PROPERTY SET ItsName(BYVAL strName AS STRING)  'didn't provide a unique and specific
          MyBase.ItsName="The Sheep"                            'Override for the base class MakeSound()
        END PROPERTY                                            'Method, so if MakeSound() is called on
                                                                    'a Sheep object the base class method
        OVERRIDE METHOD Eat() AS STRING                         'will be called (see output below).
           METHOD=MyBase.ItsName & " Ate Some Grass."
        END METHOD
    
        OVERRIDE METHOD MakeSound() AS STRING                   'term 'this'.  Its usually optional
          METHOD=MYBASE.ItsName & " Makes a baabaa Sound."      'to use it but to make the code
        END METHOD
    
      END INTERFACE
      
    
      INTERFACE ICare : INHERIT IUNKNOWN
        METHOD Groom() AS STRING
          METHOD=Me.SheepGroom()
        END METHOD
    
        METHOD Deworm() AS STRING
          METHOD="You Give The Sheep A Dose Of Dewormer."
        END METHOD
      END INTERFACE
    END CLASS
    Other than allowing for your CLASS METHOD to be used by multiple INTERFACES in the same class. What are any other reasons we should consider using a CLASS METHOD versus just laying the code straight into an INTERFACE METHOD?

    -Ken
Working...
X