📘 ملخص جامعاتنا · من الطالب للطالب
Object-Oriented Programming (C++) — المكثّف — ليلة الامتحان (المحاضرات 1–4) | جامعة العلوم والتكنولوجيا الأردنية
ملخصات جامعاتنا المجانية · مراجعة ليلة الامتحان
Object-Oriented Programming (C++) (غير محدد) — المكثّف
1. Pointers & Dynamic Memory (المؤشرات والذاكرة الديناميكية)
القوانين
- Pointer arithmetic: address(ptr + i) = address(ptr) + sizeof(T) × i
- Array/pointer: arr[i] ≡ *(arr + i) · arr ≡ &arr[0]
- Dynamic memory: int *a = new int[n]; … delete [] a; a = NULL;
- Pointer size: same for all types (4 B on 32-bit, 8 B on 64-bit)
Memory, addresses and sizes
- Memory is like a giant array of bytes; each byte has an address (32 bits long on a 32-bit computer).
- Every variable lives at an address; the address of a variable = the address of its first byte.
- Typical sizes: char 1 byte, int 4, float 4, double 8; check with sizeof().
Declaring pointers and the & / * operators
- Pointer (مؤشر): a variable whose value is a memory address: int *myPtr;