עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

operator overload בC++

Featured Replies

פורסם

משום מה רק האוברלואד הזה לא עובד לי, למה?

friend ostream& MYCLASS::operator<<(ostream& out, const MYCLASS& a) const;

ועשיתי INCLUDE לIOSTREAM

תודה.

פורסם

תגדיר "לא עובד". לא מתקמפל? מתקמפל ולא רץ? רץ ולא מחזיר תוצאות נכונות? רץ ומנסה לרצוח אותך ואת המשפחה שלך?

פורסם
  • מחבר

לא התקמפל. מחקתי את ה COSNT בסוף וזה עבד...

אבל עכשיו שוב יש לי שגיאה

זאת השורה שלי ב.H

friend ostream& operator<<(ostream& out, const MYCLASS& a);

וזה ב.CPP

friend ostream& MYCLASS::operator<<(ostream& out, const MYCLASS& a)

השגיאה היא(ב .CPP):

Error	9	error C2255: 'friend' : not allowed outside of a class definition	
Error 10 error C2039: '<<' : is not a member of 'MYCLASS'

וכשאני מוריד את ה MYCLASS:: לפני הOPERATOR השגיאה היא:

Error	9	error C2255: 'friend' : not allowed outside of a class definition

פורסם

אכן צריך להוריד את ה-MYCLASS. לגבי שגיאה 9, השגיאה אומרת לך בדיוק מה הבעיה.

פורסם
  • מחבר

אבל אז איך אני אגש לאובייקטים הפרטיים של המחלקה?

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.