I'm a
JAVA student. And no exp. in C++.
I can't understand what is gping wrong with the following programm. Please help me to correct it. Thanks in Advance.
//a simple inheritance
class box
{
double width;
double height;
double depth;
box(box obj){width=obj.width;height=obj.height;depth=obj.depth;}
box(double w, double d, double h)
{
width=w;
height=h;
depth=d;
}
double volume()
{
return width*depth*height;
}
}
class suBox extends box
{
double weight;
suBox(double w, double d, double h, double m)
{
depth=d;
height=h;
width=w;
weight=m;
}
}
public class ex9inhert
{
public static void main(
String args[])
{
suBox box1=new suBox(30, 20, 10, 45.34);
box box2=new box(30,20,40);
System.out.println(box2.volume());
System.out.println(box1.volume());
System.out.println(box1.weight);
}
}