C ++ arrow operator (->)

Source: Internet
Author: User

From C ++ a beginner's Guide by Herbert schildt chapter8 page 34

The definition as below:

You can access an object either directly (as has been the case in all preceding examples), or by using a pointer to that object. to access a specific element of an object when using a pointer to the object, you must use the arrow OPERATOR:->. it is formed by using the minus sign followed by a greater-than sign. to declare an object pointer, you use the same declaration syntax that you wowould use to declare a pointer for any other type of data. the next program creates a simple class called p_example, defines an object of that class called OB, and defines a pointer to an object of Type p_example called P. it then uses strates how to access ob directly, and how to use a pointer to access it indirectly.

This means that when you use a pointer to operate an object, you can no longer use the dot operator to access its members '. ', must use arrow operator'-> '.

 

The following is an example in the Tutorial:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.