Results 1 to 4 of 4
  1. #1
    fresh83 is offline Member
    Join Date
    Dec 2009
    Posts
    55
    Rep Power
    0

    Default How is this dog inheriting a bark?

    Yfrog Image : yfrog.com/9fscreenhunter01jul041353g

    no real problem here, but something i was suprised to find out was that somehow the dogs in the array could inherit the bark from dog1 even though only "dog" was referenced....

    so dose this mean that if i write a bike class and then refrence it as redBike
    to give it some color and gainSpeed

    then i write a blueBike object and give it a a length of 3

    then i try to code blueBike.gainSpeed
    it should work? even though no where in "bike" or blueBike" is there any declaring of gainSpeed?

  2. #2
    fresh83 is offline Member
    Join Date
    Dec 2009
    Posts
    55
    Rep Power
    0

    Default

    a simplified way of asking my question is ....any object inside of a class , gets use of the bark command , even if it was defined in a dif reference.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,415
    Rep Power
    25

    Default

    any object inside of a class , gets use of the bark command , even if it was defined in a dif reference.
    Could you show us with sample code what you are asking?
    Your terminology is hard to follow: command; defined in a reference; object in a class
    I suppose you mean method; class and class reference/pointer

  4. #4
    jackGav is offline Member
    Join Date
    Jun 2010
    Posts
    5
    Rep Power
    0

    Default

    Your method "bark" belongs to Dog, and it is public so this method could be called from anywhere using an instance of Dog.

Posting Permissions

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