Thursday 9 February 2012

Important concept covered in class

can be in a walkthrough:-

a**b   ---->  a*(*b)  ----->  a * (where b is pointing to)

1 comment:

  1. Yes, you can write any of those three method because compiler is smart enough to know b is a pointer and 'a' is just a veriable. But all must have initialized before.

    Also *b*a will return same result.

    Try the following walkthrough...


    #include
    using namespace std;

    int main() {
    int *a;
    int b = 4;
    int c = 5;
    a = &b;

    cout<<*a*c<<endl; //20
    cout<<c*(*a)<<endl; //20
    cout<<c**a<<endl; //20
    return 0;
    }

    ReplyDelete