10. Pointers in C++ - IndianTechnoEra
Latest update Android YouTube

10. Pointers in C++

what is pointers in c++
Admin

    What is pointers?

    • Pointer is a variable that points to an address of a value.
    • Pointer is a variable that stores the address of another variable.
    • Pointer is used to allocate memory at run time i.e dynamically.

    Symbols used in Pointer :

    • & (ampersand sign) : ‘Address of operator’
    • Determines the address of a variable.
    • * (asterisk sign) : indirection operator / value at address
    • * Accesses the value at the address.


    Syntax :

    Datatype *variable_name;

    Example :

    #include <iostream>
    using namespace std;
    int main ()
    {
        int a = 320;
            int *b;
                b = &a;
        cout << "Value of a variable is : ";
            cout << a << endl;
        cout << "Address stored in b variable is: ";
            cout << b << endl;
        cout << "Value of *b variable is : ";
            cout << *b << endl;
        return 0;

        }

    Output :

    Value of a variable is : 320

    Address stored in b variable is: 0x68fee8

    Value of *b variable is : 320


    Note : Pointer variable value should be integer (address).

    C Plus Plus program to create a class complex through pointers

    C++ program to create a class complex through pointers

    إرسال تعليق

    Feel free to ask your query...
    Cookie Consent
    We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
    Oops!
    It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
    AdBlock Detected!
    We have detected that you are using adblocking plugin in your browser.
    The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
    Site is Blocked
    Sorry! This site is not available in your country.