Explanation of Pointers in C++

Explanation of Pointers in C++
Slide Note
Embed
Share

In C++, pointers play a crucial role in managing memory and accessing data. This comprehensive guide covers the fundamentals of pointers, including classes, objects, referencing and dereferencing operators, as well as practical examples. Understand how to declare, use, and manipulate pointers effectively in your C++ programs.

  • C++
  • Pointers
  • Classes
  • Memory Management

Uploaded on Mar 03, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


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

  2. 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 ; };

  3. 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 () };

  4. 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

  5. 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;

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

  7. Program Referencing & Dereferencing

  8. THANKS

More Related Content