• Register
1,240 points
15 11 8

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.

More Posts

iso c++ forbids in class initialization of non const static member in C++ Lalit Kumar - Aug 3, 2020
operator overloading in c++ using friend function Lalit Kumar - Oct 14, 2020
delete v/s delete[] in C++ Lalit Kumar - Aug 11, 2020
No member named 'cout' in namespace 'std' Lalit Kumar - Oct 3, 2020
No operator << matches these operands C++ Lalit Kumar - Sep 15, 2020
invalid use non-static member function Lalit Kumar - Sep 10, 2020
what are the differences between pointer variable and a reference variable in C++? - Apr 6, 2020
Undefined reference to `std::cout' Lalit Kumar - Oct 5, 2020
What does break do in c++? Lalit Kumar - Nov 27, 2020
What does void do in C++? Lalit Kumar - Sep 6, 2020