aceess of private members????

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saumyaranjan
    New Member
    • Feb 2008
    • 5

    aceess of private members????

    hi,

    i hv a situation to use private members of super class in subclass....wha t i have to do?



    thnx in advance.
    Saumya
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by saumyaranjan
    hi,

    i hv a situation to use private members of super class in subclass....wha t i have to do?



    thnx in advance.
    Saumya
    Either make those private members protected so your subclass can access them
    directly or add getXXX() methods to your parent class.

    kind regards,

    Jos

    Comment

    • saumyaranjan
      New Member
      • Feb 2008
      • 5

      #3
      Originally posted by JosAH
      Either make those private members protected so your subclass can access them
      directly or add getXXX() methods to your parent class.

      kind regards,

      Jos

      I didn't get u. can u gv small piece of code hw will I use getxxx?

      Comment

      • Laharl
        Recognized Expert Contributor
        • Sep 2007
        • 849

        #4
        A getXXX() method is one that returns the value of the data member XXX.

        [CODE=java]
        public class A{
        private int foo;
        int getFoo(){
        return foo;
        }
        }
        [/CODE]

        Thus, if you want to access the value of foo, you call getFoo().

        Comment

        • saumyaranjan
          New Member
          • Feb 2008
          • 5

          #5
          Thnx 4 ur help........

          Comment

          Working...