עבור לתוכן
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.

overload ב - C

Featured Replies

פורסם

מישהו יודע כיצד ניתן לעשות overload ב C רגיל (לא ++)

זאת אומרת שפונקציה מסויימת תקבל מספר שונה של פרמטרים ותפעל לפי מספר הפרמטרים שקיבלה?

פורסם

אין כזו אפשרות ב-C. השיטה הנפוצה היא פשוט לתת שמות שונים לפונקציות.

אופציה אחרת היא לכתוב פונקציה שיכולה לקבל מספר משתנה של ארגומנטים, ככה:

http://www.cprogramming.com/tutorial/lesson17.html

שים לב שאין דרך לדעת בזמן קומפילציה מה הטיפוסים של הארגומנטים (מבחינת הקומפיילר זה הכל זה *void) ולכן אתה צריך להעביר את המידע הזה לפונקציה איכשהו (באמצעות פרמטרים נוספים, לדוגמה).

פורסם

אני חושב שהוא דיבר על va_list כמו ב-printf.

תחפש ברשת, הנה משהו שחפרתי מגוגל: http://bobobobo.wordpress.com/2008/01/28/how-to-use-variable-argument-lists-va_list/

וגם http://publications.gbdirect.co.uk/c_book/chapter9/stdarg.html

בקצרה:

1) מגדירים פונקציה שמקבלת פרמטרים ומסתיימת ב- ...

2) חייבת להיות דרך שהפונקציה תוכל לדעת בזמן ריצה כמה פרמטרים יש ואיזה סוג כל פרמטר. לדוגמא printf מפענחת את מחרוזת הפורמט שהוא הפרמטר הראשון.

3) בתוך הפונקציה משתמשים ב-va_list va_arg והחברים שלהם.

ארכיון

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

דיונים חדשים

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.