C++ Member Operators
The . (dot) operator and -> (arrow) operator are used to reference members of classes, structures, and unions.
The dot operator is applied to actual objects. The arrow operator is used with a pointer to an object. For example, suppose there is the following structure:
struct Employee {
char first_name[16];
int age;
} emp;
The . (dot) Operator
The following code assigns the value "zara" to the first_name member of the object emp:
strcpy(emp.first_name, "zara");
The -> (arrow) Operator
If p_emp is a pointer to an object of type Employee, to assign the value "zara" to the **first_name** member of the object emp, you would write the following code:
strcpy(p_emp->first_name, "zara");
-> is called the arrow operator, which consists of a minus sign followed by a greater-than sign.
In summary, use the dot operator to access members of a structure, and use the arrow operator to access members of a structure through a pointer.