Hello.
Here is the class that stores information about the military: Name and Age.
class Military { private: char FIO; int Age; public: Military(char FIOName, int A):FIO(FIOName),Age(A){}; Military(){}; ~Military(){}; char get_FIO(){return FIO;}; int get_Age(){return Age;}; void set_F(char FIOName){FIO=FIOName;}; void set_Age(int A){Age=A;};
His descendant - Private: (year of service, branch of service + name and age from the parent class Military )
class Soldier: public Military { private: int YearOfServ; char TypeOfForces; //Π³ΠΎΠ΄ ΡΠ»ΡΠΆΠ±. ΡΠΎΠ΄ Π²ΠΎΠΉΡΠΊ public: Soldier(int YOS, char TOF, char FIOName, int A): Military(FIOName),Military(A),YearOfServ(YOS),TypeOfForces(TOF){}; Soldier(){}; ~Soldier(){}; int get_YearOfServ(){return YearOfServ;}; char get_TypeOfForces(){return TypeOfForces;}; void set_YearOfServ(int YOS){YearOfServ=YOS;}; void set_TypeOfForces(char TOF){TypeOfForces=TOF;}; }
When I try to compile, I get the error: Could not find a match for 'Military :: Military (char)'
in line
Military(FIOName),Military(A),YearOfServ(YOS),TypeOfForces(TOF){};
And in it is the same error Base class 'Military' is initialized more than once
And everything would be fine, having given an example from the training manual, it works perfectly, although everything is still there, just not military, but geometric figures.
Parent:
class Figure {private: int Color;//ΠΏΠΎΠ»Π΅ ΠΊΠ»Π°ΡΡΠ°, Π΄ΠΎΡΡΡΠΏΠ½ΠΎΠ΅ ΡΠΎΠ»ΡΠΊΠΎ ΠΊΠ»Π°ΡΡΡ public://ΠΌΠ΅ΡΠΎΠ΄Ρ ΠΊΠ»Π°ΡΡΠ°, Π΄ΠΎΡΡΡΠΏΠ½ΡΠ΅ ΠΊΠ»Π°ΡΡΠ°ΠΌ-ΠΏΠΎΡΠΎΠΌΠΊΠ°ΠΌ ΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ΅ Figure(int PC):Color(PC){}; Figure(){}; ~Figure(){}; int get_Color(){return Color;}; void set_Color(int PC){Color=PC;}; virtual AnsiString Info() {AnsiString res; switch (Color) { case 1:res="ΠΊΡΠ°ΡΠ½ΡΠΉ"; break; case 2:res="ΠΎΡΠ°Π½ΠΆΠ΅Π²ΡΠΉ"; break; case 3:res="ΠΆΠ΅Π»ΡΡΠΉ";break; case 4:res="Π·Π΅Π»Π΅Π½ΡΠΉ"; break; case 5:res="Π³ΠΎΠ»ΡΠ±ΠΎΠΉ"; break; case 6:res="ΡΠΈΠ½ΠΈΠΉ"; break; case 7:res="ΡΠΈΠΎΠ»Π΅ΡΠΎΠ²ΡΠΉ"; break; };return res;};
Descendant: (Circle, where X, Y-coordinates of the center, R - radius)
class Circle: public Figure {private: int X,Y,R; public: Circle(int PX,int PY,int PR,int PC): Figure(PC),X(PX),Y(PY),R(PR){} Circle(){} int get_X(){return X;} int get_Y(){return Y;} int get_R(){return R;} void set_X(int PX){X=PX;}; void set_Y(int PY){Y=PY;}; void set_R(int PR){R=PR;}; }
In line
Circle(int PX,int PY,int PR,int PC):Figure(PC),X(PX),Y(PY),R(PR){}
Similarly, there is an appeal to the RS parameter which determines the color, by specifying the class to which this parameter belongs. Figure (PC) And there are no such errors as I do.