• Register
100 points
7 2
Welcome to Kodlogs, programming questions and answer website.

The -> symbol like is called arrow operator which is formed by using minus sign followed by greater than sign. The operator is used in C++ to reference individual members of classes, structures or unions. The dot operator is applied to denote the actual object while the arrow operator is used with a pointer to an object.

Example and explanations

Struct Employee {

Char first _name [16 ];

Int age;

} emp

The object as denoted by dot of the string is first name. Let us say we assign the first name to be Lalit of the member of emp , the following will apply;

Strcpy( emp. first _name, “Lalit”);

Note the (.) dot sign before the ‘first name’ indicates the object.

In a case where the p_emp is a pointer to an object of the employee, then to assign the name Lalit to the first name of the object will be written as follows:

Strrcpy(p_emp->first _name, “Lalit”);

The simple meaning of the arrow operator is to aid access of members of a structure through a pointer by using arrow operator.

Hope it helps.

100 points
7 2