Как я могу исправить ошибки из кода, который я доказал
Я написал программу, которая должна была получить результат
10
00
10
ничего не меняя в основной функции, но я получил много ошибок, помогите, пожалуйста
ошибка:
C:\Users\Silas\Desktop\rsp2.cpp:37: error: expected `;' before '(' token C:\Users\Silas\Desktop\rsp2.cpp:44: error: expected `;' before "bool" C:\Users\Silas\Desktop\rsp2.cpp:44: error: expected `;' before '(' token C:\Users\Silas\Desktop\rsp2.cpp:50: error: expected `;' before '}' token C:\Users\Silas\Desktop\rsp2.cpp:51: error: no `void Scissors::setStrength(int)' member function declared in class `Scissors' C:\Users\Silas\Desktop\rsp2.cpp:67: error: expected `;' before '(' token C:\Users\Silas\Desktop\rsp2.cpp:72: error: expected `;' before '}' token C:\Users\Silas\Desktop\rsp2.cpp: In member function `bool Paper::fight(Scissors)': C:\Users\Silas\Desktop\rsp2.cpp:15: error: `int Tool::strength' is protected C:\Users\Silas\Desktop\rsp2.cpp:64: error: within this context C:\Users\Silas\Desktop\rsp2.cpp: At global scope: C:\Users\Silas\Desktop\rsp2.cpp:73: error: no `void Paper::setStrength(int)' member function declared in class `Paper' C:\Users\Silas\Desktop\rsp2.cpp: In member function `bool Rock::fight(Paper)': C:\Users\Silas\Desktop\rsp2.cpp:15: error: `int Tool::strength' is protected C:\Users\Silas\Desktop\rsp2.cpp:87: error: within this context C:\Users\Silas\Desktop\rsp2.cpp: In member function `bool Rock::fight(Scissors)': C:\Users\Silas\Desktop\rsp2.cpp:15: error: `int Tool::strength' is protected C:\Users\Silas\Desktop\rsp2.cpp:94: error: within this context C:\Users\Silas\Desktop\rsp2.cpp: At global scope: C:\Users\Silas\Desktop\rsp2.cpp:97: error: no `void Rock::setStrength(int)' member function declared in class `Rock' C:\Users\Silas\Desktop\rsp2.cpp: In function `int main()': C:\Users\Silas\Desktop\rsp2.cpp:105: error: no matching function for call to `Scissors::Scissors(int)' C:\Users\Silas\Desktop\rsp2.cpp:35: note: candidates are: Scissors::Scissors() C:\Users\Silas\Desktop\rsp2.cpp:35: note: Scissors::Scissors(const Scissors&) C:\Users\Silas\Desktop\rsp2.cpp:106: error: no matching function for call to `Paper::Paper(int)' C:\Users\Silas\Desktop\rsp2.cpp:59: note: candidates are: Paper::Paper() C:\Users\Silas\Desktop\rsp2.cpp:59: note: Paper::Paper(const Paper&) C:\Users\Silas\Desktop\rsp2.cpp:107: error: no matching function for call to `Rock::Rock(int)' C:\Users\Silas\Desktop\rsp2.cpp:81: note: candidates are: Rock::Rock() C:\Users\Silas\Desktop\rsp2.cpp:81: note: Rock::Rock(const Rock&) C:\Users\Silas\Desktop\rsp2.cpp:108: error: 'class Scissors' has no member named 'fight' C:\Users\Silas\Desktop\rsp2.cpp:108: error: 'class Paper' has no member named 'fight' C:\Users\Silas\Desktop\rsp2.cpp:109: error: 'class Paper' has no member named 'fight' C:\Users\Silas\Desktop\rsp2.cpp:109: error: 'class Rock' has no member named 'fight' C:\Users\Silas\Desktop\rsp2.cpp:110: error: 'class Rock' has no member named 'fight' C:\Users\Silas\Desktop\rsp2.cpp:110: error: 'class Scissors' has no member named 'fight' Execution terminated
Что я уже пробовал:
#include <iostream> using namespace std; class Tool { protected: int strength; char type; public: int result; void setStrength (int) { strength = 0; type = ' '; } int getStrength() { return strength; } char getType() {return type; } }; //SCISSOR CLASS******************************************* class Scissors: public Tool { public: bool fight(Paper) { Paper p1; Scissors s1; return p1.strength < s1.strength; } bool fight(Rock) { Scissors s1; Rock r1; return r1.strength < s1.strength; } }; void Scissors::setStrength (int x) { strength = x; type = 's'; } //PAPER CLASS********************************************* class Paper : public Tool { public: bool fight(Scissors) { Paper p1; Scissors s1; return p1.strength < s1.strength; } bool fight(Rock) { Paper p1; Rock r1; return r1.strength < p1.strength; } }; void Paper::setStrength (int x) { strength = x; type = 'p'; } //ROCK CLASS*********************************************** class Rock : public Tool { public: bool fight(Paper) { Paper p1; Rock r1; return p1.strength < r1.strength; } bool fight(Scissors) { Rock r1; Scissors s1; return r1.strength < s1.strength; } }; void Rock::setStrength (int x) { strength = x; type = 'r'; } //MAIN FUNCTION******************************************** int main() { Scissors s1(5); Paper p1(7); Rock r1(15); cout << s1.fight(p1) << p1.fight(s1) << endl; cout << p1.fight(r1) << r1.fight(p1) << endl; cout << r1.fight(s1) << s1.fight(r1) << endl; return 0; }