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
• Pointers
# 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
1) 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

pointer-to-object-.pptx

  • 1.
    CONTENTS • Pointer. • Explanationof Class. • Explaination of Object. • Referencing Operator & Dereferencing Operator. • Program Explanation. • Explaination of Pointer to Object. POINTER
  • 2.
    • CLASS # AClass 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 ; };
  • 3.
    • Object # Anobject 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 () };
  • 4.
    • Pointer toObject # 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
  • 5.
    • Pointers # Pointeris 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;
  • 6.
    REFERENCING OPERATOR &DEREFERENCING OPERATOR 1) Address of Operator (Reference operator &) :- Syntax- &variable name e.g P=&X; 2) Dereferencing Operator ( Value of Operator * ):- e.g y=*p;
  • 7.
    Program Referencing &Dereferencing
  • 8.