Scope Resolution Operator
- Represented by
::
, it is used to access global variables (when there is a conflict with local variables), namespace members, nested classes, and static members (though static members are just one common use case)
How is it different from
.
?
.
is used to access non-static members of an object (instance) of a class.
How is it different from Java's
::
?In Java,
::
is a method reference operator used for referencing methods or constructors in a more functional programming style.
Type Inference
Block-based Class Structure
- In C++, access modifiers (
public
,private
,protected
) are block-based. They apply to all members declared after them until another access modifier appears
Pointer vs Reference
- References in C++ are an alias for an existing variable
- For structure, accessing attributes with pointer to a structure requires
->
, but reference can access directly with.