On Inheritance

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sasimca007
    New Member
    • Sep 2007
    • 129

    On Inheritance

    Hello friends,
    How to access the variables of parent class in the child class?
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    Originally posted by sasimca007
    Hello friends,
    How to access the variables of parent class in the child class?
    How to access Google?

    What have you done so far?

    regards,
    sukatoa

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by sasimca007
      Hello friends,
      How to access the variables of parent class in the child class?
      If the variables in the parent class aren't private you can simply access them as
      if they're your own. I consider this bad practice because it couples the base class
      to the child class even tighter. Have you read a book about this matter or are
      you simply asking your homework questions here?

      kind regards,

      Jos

      Comment

      • lotus18
        Contributor
        • Nov 2007
        • 865

        #4
        Originally posted by sasimca007
        Hello friends,
        How to access the variables of parent class in the child class?
        You can use the extends keyword then followed by the name of the class to inherit from.

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by lotus18
          You can use the extends keyword then followed by the name of the class to inherit from.
          Yes but that was not what the OP was asking; given his question he seems to
          know how to build a child and parent class; he was asking how to access the
          variables in the parent class from the child class.

          kind regards,

          Jos

          Comment

          Working...