No you don't need do. But if you want to call the base constructors you
just call super with the appropriate parameters.Also you can create new
constructors for your new class that extends the base one! For example!

public class base {
        public base(){
               int i = 0;
        }
}


public class newBase extends base {

        public newBase(){
              super();//if you want to call the mother constructor
              int i=0;
        }

}


On Thu, Nov 29, 2012 at 7:34 PM, Simon Giddings <[email protected]>wrote:

> This may seem a bit basic, but I come from a C++ background and it is
> confusing me a little.
>
> When I extend a base class, do I need to create a constructor for each
> base class constructor ?
> What I mean is this. Given :
>
> public class base
> {
>     protected int m_iValue;
>
>     public base()
>     {
>         m_iValue = 0;
>     }
>
>     public base(int iVal)
>     {
>         m_iValue = iVal;
>     }
> }
>
> If I want to create a new class based on this base class, will I need to
> declare the two constructors again for them to be visible ?
> The following seems to hide the second constructor of the base class.
>
> public class Derived extends base
> {
>     public Derived()
>     {
>         super();
>     }
> }
>
> What is the correct way to do this ?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to