pointer-to-object-.pptx

ZaibunnisaMalik1 524 views 8 slides Nov 01, 2022
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

understanding pointer


Slide Content

Contents Pointer . Explanation of Class . Explaination of Object. Referencing Operator & Dereferencing Operator. Program Explanation. Explaination of Pointer to Object. POINTER

CLASS A Class is a user defined data type which has data member & member functions. It is declared by using keyword “Class”. Syntax : Class class_name { access specifier : data members; member function () }; Example: Class car { private : int spd lmt ; int inc.spd ; };

Object An object is an instance(occurence) of a class, when a class is defined no memory is allocated but when object is created memory is allocated. Syntax: Class_name obj_name; Example: Class student { private : int roll; char name [10]; public : void getdata () void putdata () };

Pointer to Object Just like other pointers, the object pointers are declared by placing in front of a object pointer’s name. Syntax : class_name * object_pointer_name ; Eg. date * ptr ; To access the public members using an object Dot ( . ) operator is used, and to access public membes using object pointer, the arrow ( -> ) operator is used

P ointers Pointer is a vaiable which is used to store memory address of another variable. Pointer is basically derived data type of C++. Declaration of Pointer Syntax: data_type * variable_name ; Eg. 1. int * ptr ; 2. float * ptr ; 3. char * ptr ;

REFERENCING OPERATOR & DEREFERENCING OPERATOR Address of Operator (Reference operator &) :- Syntax- &variable name e.g P=&X; 2 ) Dereferencing Operator ( Value of Operator * ):- e.g y=*p;

Program Referencing & Dereferencing

THANKS