pointer variable and pointer to pointer variable in c++

 #include<iostream>

using namespace std;

int main() {
    //what is a pointer---> a data type which stores the address of other data types
    //hmare device ki memory(ram) mein ek address assign kiya jata hai which is given by "&"

    int a=5;
    int* b = &a;

    // or
    // int* b;
    // b = &a;

    cout<<"the address of a is "<<b<<endl;
    cout<<"the address of a is "<<&a<<endl;

    //int*---> pointer (data type)
    //&---> address of operator

    //*---> dereference operator (value at)

    cout<<"the value at address of b is "<<*b<<endl;

    //pointer to pointer---> ek esa pointer jo pointer ke address ko store krta hai

    int** c = &b;

    cout<<"the address of b is "<<c<<endl;
    cout<<"the address of b is "<<&b<<endl;
    cout<<"the value at address of c is "<<*c<<endl;
    cout<<"the value at address value_at(value_at(c)) is "<<**c<<endl;

    return 0;

}

Comments

Popular posts from this blog

Function Overloading in C++

oops recall, basic operations and nesting of member functions

OBJECT ORIENTED PROGRAMMING, classes public and private access modifiers (syntax)