Suppose you have a pointer a and you want to access data member b of a class.View more random threads:
- stack during function call in C++ 2011
- Variable Access Speed in C++
- , Node* new node = new Node(9) its mean new node points to...
- Problem with the complexity of the program 2011
- What is meant by "pass by value and pass by reference" in...
- Vector of stucts in c++ 2011-12
- A data member can be member of any class oject or any...
- Changing text color in c++ 2011
- how to use system("pause"); in Dec C++
- code c++
Now if you will write:
*a.b
it will not work as (.) is evaluated before (*)
Sponsored Links
But if you will write:
(*a).b
it will access b, because now (*a) will be evaluated first because of the brackets.
The alternate way is to use:
a->b
Now it is simple and there is not any confusion.
So, you can say that (*a).b = a->b, that is, both have the same effect.
There are currently 1 users browsing this thread. (0 members and 1 guests)