Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Thanked 0 Times in 0 Posts

    Methods Inheritance?

    Hi everyone,

    I am looking for some help with the following question.

    I have 2 classes, Bird and AngryBird. AngryBird is a extension of Bird.

    Both classes have a method called changeColour() which do different things.

    If I use changeColour() in the AngryBird Class it automatically runs the AngryBird's changeColour() method.

    What I am looking to do is make it so that, the attributes from the Bird's changeColour() method are also given to an object I use changeColour on...

    If I have an object called bird1 as an AngryBird. If I put bird1.changeColour();

    I would like the object to run through the Bird changeColour method and the AngryBird ChangeColour method.

    Is this possible?

    I am not sure if I have been 100% clear, I can post some code if its easier when I get home from work.



  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,660 Times in 2,629 Posts
    You are not being clear. For attributes are you meaning your class members or are you meaning your method parameters?
    For member properties, you need to flag them as protected and not private if you want to directly access them from an extended class. Parameters have to match, otherwise you are not overriding the changeColour method and only overloading it with a new definition.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts