Skip to main content

Posts

Showing posts from September 13, 2020

Pointers.

I have already introduced pointers in the C++ Derived Data Types post , But, here I will be showing some practical examples and at the end of this slide, you will be understanding pointers like they are, obvious to you. So, let' start by reminding you the basic syntax :- <data type> *<name_of_pointer> ; Below is the simple program for pointer declaration and initialization. #include<iostream> using namespace std; int main (){ int a = 20 ; int *b; // Declaration of pointer b b = &a; // Initialization of pointer b (& is used to extract the address of a) int *c = b; // Initialization of pointer c to pointer b cout << a << endl << b << endl << c << endl; } Okay, after reminding the basic syntax of pointers, you have to memorize the reason why we generally use pointers, I have already discussed that also, but, let me briefly describe it. One of the memory section in our Comp