Functions signature A functions signature is a combination
חזרה – פונקציות Function’s signature A function's signature is a combination of the function's name; the number, order, and types of its parameters; as well as any qualifiers that can be applied to the function. http: //www. bookrags. com/sciences/computerscience/function-signaturewcs. html 10 . © כל הזכויות שמורות. נכתב ע"י יעל ארז
struct – חזרה שם המבנה members struct point{ int x; int y; }; void main() { struct point my_point = { 3, 7 }; struct point *p = &my_point; (*p). x = 8; p->x = 8; } 14 . © כל הזכויות שמורות. נכתב ע"י יעל ארז
pointers & references – הרחבות Call by reference void swap(int& a, int &b) { int tmp; tmp=a; a=b; b=tmp; } 26 . © כל הזכויות שמורות. נכתב ע"י יעל ארז
Memory leaks – הרחבות CRT library : memory leak detection enabling : כדי שנוכל להשתמש בכלי זה יש להגדיר בתוכנית #define _CRTDBG_MAP_ALLOC #include <stdlib. h> #include <crtdbg. h> ל free ו malloc ממפה את הפונקציות _free_dbug _ ו malloc_dbg _Crt. Dump. Memory. Leaks() כדי לקבל מידע נקרא לפונקציה 40 . © כל הזכויות שמורות. נכתב ע"י יעל ארז
Memory leaks – הרחבות CRT library : memory leak detection enabling : delete ו new אם רוצים לעבוד עם #ifdef _DEBUG #ifndef DBG_NEW #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ ) #define new DBG_NEW #endif // _DEBUG 41 . © כל הזכויות שמורות. נכתב ע"י יעל ארז
Function overloading – הרחבות int add(int a, int b, int c) { cout<<"int, int"<<endl; return a+b+c; } int add(int a, int b, double c) { cout<<"int, double"<<endl; return a+b+c; } 43 . © כל הזכויות שמורות. נכתב ע"י יעל ארז
Default parameters – הרחבות #include <iostream> using namespace std; void print (int a=1, int b=2, int c=3) { cout<<"a="<<a<<" b="<<b<<" c="<<c<<endl; } int main() { print(11, 22, 33); print(100, 200); print(17); return 0; } 46 . © כל הזכויות שמורות. נכתב ע"י יעל ארז
? מה למדנו Pointers & references § const keyword § Memory leaks § Function overloading § Default parameters § Operator overloading § 56 . © כל הזכויות שמורות. נכתב ע"י יעל ארז
- Slides: 47