Hi,
When you define a constructor for a class with some argument compiler does not create the default(no argument constructor) for you. When you instantiate your subclass all your base classes must be properly initialized. In this case the only way to instantiate a Top object is via Top(double d) hence in the constructor for your subclass you have to make a explicit call to superclasses constructor providing it with the right argument.
If you don't do it then compiler will complain that it cannot find constructor Top() that is because when you don't explicitly call super classes constructor then compiler synthesizes an automatic super() call. Since your super class does not have a constructor that matches this call the program will not compile.
Hope it makes sense
regards
Originally posted by Susmita Pal:
Yes, it compiles fine when we add
super(d);
can any body explain why it is needed.
Thankx to everybody for explaining me.