ערכתי לאחרונה בתאריך 23.09.07 בשעה 21:13 בברכה, Limp Bizkit
כתבתי לי לתומי מחלקה בקובץ מימוש ... #ifndef POINT_H #define POINT_Hclass Point { friend ostream &operator<<(ostream &, const Point &); public: Point(int=0,int=0); // default constructor void setpoint(int,int); // set coordinates int getx() const {return x;} // get x coordinates int gety() const {return y;} // get y coordinates protected: // accessible by derived classes int x,y; // x and y coordinates of the Point }; #endif
|
ובניתי עוד מחלקה שתירש את התכונות של מחלקה Point (בקובץ מימוש אחר)
באתי לקמפל, וזה מביא לי את השגיאה הבאה (אני מתכנת בלינוקס):
point.h:6: error: ISO C++ forbids declaration of ‘ostream’ with no type point.h:6: error: ‘ostream’ is neither function nor member function; cannot be declared friend point.h:6: error: expected ‘;’ before ‘&’ token point.h: In function ‘std::ostream& operator<<(std::ostream&, const Point&)’: point.h:13: error: ‘int Point::x’ is protected point.cpp:19: error: within this context point.h:13: error: ‘int Point::y’ is protected
|
אני פשוט משתגע מה הבעיה, בדקתי את התוכנית אלפי פעמים
תודה רבה לעוזרים 

Ask any racer, any real racer. It doesn't matter if you win by an inch or a mile; winning's
winning.