Home > Back-end >  I don't know where is wrong?
I don't know where is wrong?

Time:09-26

#include
using namespace std;
The class Point
{
Public:
Point (int A, int B)
{x=A;
Y=B;
}
Void the show ()
{
cout<" The point is: "& lt; <" (" & lt; & lt; X<" , "& lt; & lt; Y<" ) "& lt; & lt; Endl;

}
Protected:
Int x, y;
};


The class Retangle: public Point
{
Public:
B Retangle (int, int, int L, int W) : Point (int A, int B)
{
L=l;
W=w;
}
Void show1 ()
{
cout<" The Long and Width is: "& lt; & lt; L<" AND "& lt; & lt; W<& lt; Endl;
}
Protected:
Int l, w;
};



The class Cube: public Retangle
{
Public:
Cube (int A, B int, int L, int W, int H) : Retangle (int A, B int, int L, int W)
{
H=h;
}
Void show2 ()
{
cout<" The Hight is "& lt; & lt; h<& lt; Endl;
}
Protected:
Int h;
};
Int main ()
{
Cube T (1, 2, 3, 4, 5);
cout<" The data is: "& lt; & lt; Endl;
T.s how ();
T.s how1 ();
T.s how2 ();
return 0;
}

CodePudding user response:

This kind of question the compiler will give you more clear hint, don't need to ask, a down there are two obvious errors, the reason for the error:
Public:
B Retangle (int, int, int L, int W) : Point (int A, int B)
To the base class passing parameters need with variables directly, rather than the prototype again, it should be: Retangle (int A, B int, int L, int W) : Point (A, B
In the same way this is wrong:
Public:
Cube (int A, B int, int L, int W, int H) : Retangle (int A, B int, int L, int W)
Should be changed to
Cube (int A, B int, int L, int W, int H) : Retangle ( A, B, L, W
  • Related