Difficulty: Easy
Correct Answer: A class object and a member of that class.
Explanation:
Introduction / Context:
The dot operator is the standard member-access operator for objects in C++. Correctly identifying what appears on each side clarifies how to read and write idiomatic code.
Given Data / Assumptions:
Concept / Approach:
Member access uses object.member. For pointer-to-object, use the arrow operator: ptr->member. To access static members without an instance, qualified lookup uses ClassName::member. Thus, dot specifically connects an object on the left to a member of that object’s class on the right.
Step-by-Step Solution:
1) Point p; p.x; → object p to its data member x.2) p.length(); → object p to its member function length().3) Point::origin(); → uses scope operator, not dot (class to static member).4) Point* q; q->x; → uses arrow, not dot.
Verification / Alternative check:
Compile examples using dot vs arrow vs scope operator to see which combinations are allowed.
Why Other Options Are Wrong:
Class-to-member uses ::, not .Member-to-object order is reversed; the left must be the object.Namespaces use :: for qualified lookup, not .
Common Pitfalls:
Attempting to use dot on pointers (should use ->), or using dot with class names instead of instances for static members (should use ::).
Final Answer:
A class object and a member of that class.
Discussion & Comments