Which operator is normally used to access a public data member of a structure object in C++?
Options
- A. .
- B. ->
- C. ::
- D. More than one of the above
- E. None of the above
Quiz Practice:
A. .
Answer: (A) .
The dot operator (.) is used to access a member through an object directly.
For example:
struct Student { int marks; };
Student s;
s.marks = 90;
Here, s.marks uses the dot operator.
The -> operator is generally used when accessing a member through a pointer to an object.