انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Pointer and Reference

Share |
الكلية كلية العلوم للبنات     القسم قسم الحاسبات     المرحلة 2
أستاذ المادة حسنين علي عبيس عبود آل عيسى       29/05/2019 06:02:17
Pointer and Reference

Understanding how pointers and references work is one step toward being able to
write programs that are effective in their consumption of system resources.
In this lesson, you find out
What pointers are
What the free store is
How to use operators new and delete to allocate and free memory
How to write stable applications using pointers and dynamic allocation
What references are
Differences between pointers and references
When to use a pointer and when to use references

What Is a Pointer?

Put simply, a pointer is a variable that stores an address in memory. Just the same way
as a variable of type int is used to contain an integer value, a pointer variable is one
that is used to contain a memory address, as illustrated in the following Figure.

Thus, a pointer is a variable, and like all variables a pointer occupies space in memory
(in the case of Figure, at address 0x101). What’s special about pointers is that the
value contained in a pointer (in this case, 0x558) is interpreted as a memory address.
So, a pointer is a special variable that points to a location in memory.

Declaring a Pointer

A pointer being a variable needs to be declared, too. You normally declare a pointer
to point to a specific value type (for example, int). This would mean that the address
contained in the pointer points to a location in the memory that holds an integer. You
can also specify a pointer to a block of memory (also called a void pointer).
A pointer being a variable needs to be declared like all variables do:

PointedType * PointerVariableName;


المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
download lecture file topic