Ĺadny brzuch
Co w tym kodzie jest źle?:
#include <iostream> using namespace std; class Rectangle { public: Rectangle(int width, int height); ~Rectangle() {} void DrawShape() const; void DrawShape(int aWidth, int aHeight) const; private: int itsWidth; int itsHeight; }; Rectangle::Rectangle(int width, int height) { itsWidth = width; itsHeight = height; } void Rectangle::DrawShape() const { DrawShape(itsWidth, itsHeight); } void Rectangle::DrawShape(int width, int height) { for(int i = 0; i < height; i++) { for(int j = 0; j < width; j++) { cout << "*"; } cout << "\n"; } } int main() { Rectangle theRect(30, 5); cout << "DrawShape():\n"; theRect.DrawShape(); cout << "\nDrawShape(40, 2):\n"; theRect.DrawShape(40, 2); system("pause"); return 0; }
#include <iostream> using namespace std; class Rectangle { public: Rectangle(int width, int height); ~Rectangle() {} void DrawShape() const; void DrawShape(int aWidth, int aHeight) const; private: int itsWidth; int itsHeight; }; Rectangle::Rectangle(int width, int height) { itsWidth = width; itsHeight = height; } void Rectangle::DrawShape() const { DrawShape(itsWidth, itsHeight); } void Rectangle::DrawShape(int width, int height) const { for(int i = 0; i < height; i++) { for(int j = 0; j < width; j++) { cout << "*"; } cout << "\n"; } } int main() { Rectangle theRect(30, 5); cout << "DrawShape():\n"; theRect.DrawShape(); cout << "\nDrawShape(40, 2):\n"; theRect.DrawShape(40, 2); system("pause"); return 0; }
Co w tym kodzie jest źle?: A czytac komunikaty to nie laska ?
ble.cpp:29: error: prototype for 'void Rectangle::DrawShape(int, int)' does not match any in class 'Rectangle'
ble.cpp:11: error: candidates are: void Rectangle::DrawShape(int, int) const
ble.cpp:24: error: void Rectangle::DrawShape() const
Jak byk jest napisane.
(Po namysle - chyba, ze to byl rodzaj testu dla nas :naughty: )
Użytkownik st3tc edytował ten post 09 styczeń 2006, 09:41
zanotowane.pl doc.pisz.pl pdf.pisz.pl zsf.htw.pl
#include <iostream> using namespace std; class Rectangle { public: Rectangle(int width, int height); ~Rectangle() {} void DrawShape() const; void DrawShape(int aWidth, int aHeight) const; private: int itsWidth; int itsHeight; }; Rectangle::Rectangle(int width, int height) { itsWidth = width; itsHeight = height; } void Rectangle::DrawShape() const { DrawShape(itsWidth, itsHeight); } void Rectangle::DrawShape(int width, int height) { for(int i = 0; i < height; i++) { for(int j = 0; j < width; j++) { cout << "*"; } cout << "\n"; } } int main() { Rectangle theRect(30, 5); cout << "DrawShape():\n"; theRect.DrawShape(); cout << "\nDrawShape(40, 2):\n"; theRect.DrawShape(40, 2); system("pause"); return 0; }
#include <iostream> using namespace std; class Rectangle { public: Rectangle(int width, int height); ~Rectangle() {} void DrawShape() const; void DrawShape(int aWidth, int aHeight) const; private: int itsWidth; int itsHeight; }; Rectangle::Rectangle(int width, int height) { itsWidth = width; itsHeight = height; } void Rectangle::DrawShape() const { DrawShape(itsWidth, itsHeight); } void Rectangle::DrawShape(int width, int height) const { for(int i = 0; i < height; i++) { for(int j = 0; j < width; j++) { cout << "*"; } cout << "\n"; } } int main() { Rectangle theRect(30, 5); cout << "DrawShape():\n"; theRect.DrawShape(); cout << "\nDrawShape(40, 2):\n"; theRect.DrawShape(40, 2); system("pause"); return 0; }
Co w tym kodzie jest źle?: A czytac komunikaty to nie laska ?
ble.cpp:29: error: prototype for 'void Rectangle::DrawShape(int, int)' does not match any in class 'Rectangle'
ble.cpp:11: error: candidates are: void Rectangle::DrawShape(int, int) const
ble.cpp:24: error: void Rectangle::DrawShape() const
Jak byk jest napisane.
(Po namysle - chyba, ze to byl rodzaj testu dla nas :naughty: )
Użytkownik st3tc edytował ten post 09 styczeń 2006, 09:41