Object Oriented Programming: Chapter 4: Pointers and Runtime Polymorphism

Pointer Types

C++ Object Oriented Programming

Questions: 1. Explain various types of pointers in C++. 2. Explain about pointers with an example.

Pointer Types

There are various pointer type declarations. For example ‒

If we declare the integer pointer variable as

     int *ptr;

then,

 

1. Reference

Pointers and Runtime Polymorphism

To assign the reference variable to the pointer variable we can declare it as ptr=&marks;//suppose marks is a variable whose address can be assigned to the ptr

 

2. NULL

The special value 0 can be assigned to the pointer variable. Sometimes it denotes the end of the data structure such as linked list. It can be declared as

ptr=0;

 

3. Type casting

For converting the data type the typecasting is done. Following illustration shows that the type casting is done with the absolute value to avoid type error

ptr=static_cast<int*>(1255)

The absolute memory address 1255 is used in this type casting.

 

Review Questions

1. Explain various types of pointers in C++.

2. Explain about pointers with an example.

 

Object Oriented Programming: Chapter 4: Pointers and Runtime Polymorphism : Tag: Oops, Computer Programming : C++ Object Oriented Programming - Pointer Types


Object Oriented Programming: Chapter 4: Pointers and Runtime Polymorphism



Under Subject


Object Oriented Programming (OOPs)

CS25C07 2nd Semester CSE, CSE(CY) Depts | 2025 Regulation | 2nd Semester 2025 Regulation



Related Subjects


English Essentials II

EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation



Linear Algebra

MA25C02 2nd Semester | 2025 Regulation


Applied Physics (CSIE) II

PH25C03 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Digital Principles and Computer Organization

CS25C06 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Electrical and Electronics Engineering

EE25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Object Oriented Programming (OOPs)

CS25C07 2nd Semester CSE, CSE(CY) Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Re-Engineering for Innovation

ME25C05 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Object Oriented Programming (OOPs) - Laboratory

CS25C07 2nd Semester CSE, CSE(CY) Depts | 2025 Regulation | 2nd Semester 2025 Regulation