One will compile, one won’t. this
is a pointer, and you can’t apply .
to a pointer. Use ->
to access members of the object it points to.
More Related Contents:
- C++ [] array operator with multiple arguments?
- Operator Overloading in C++ as int + obj
- C compound assignment operator ^= mean [duplicate]
- What are the basic rules and idioms for operator overloading?
- What is the difference between the dot (.) operator and -> in C++? [duplicate]
- Initializer lists and RHS of operators
- Why don’t C++ compilers define operator== and operator!=?
- Why is ‘this’ a pointer and not a reference?
- What are the pointer-to-member operators ->* and .* in C++?
- Conversion constructor vs. conversion operator: precedence
- Why does C++ need the scope resolution operator?
- What is the “–>” operator in C++?
- C++ Double Address Operator? (&&)
- What does ‘&’ do in a C++ declaration?
- What is the meaning of “operator bool() const”
- std::shared_ptr of this
- Multiple preincrement operations on a variable in C++(C ?)
- insert vs emplace vs operator[] in c++ map
- C++ overload operator [ ][ ]
- Can a cast operator be explicit?
- Order of execution in operator
- Excessive use of `this` in C++ [duplicate]
- Why is “operator void” not invoked with cast syntax?
- What is the value category of the operands of C++ operators when unspecified?
- Use of “this” keyword in C++ [duplicate]
- Is it safe to use the “this” pointer in an initialization list?
- Two ‘==’ equality operators in same ‘if’ condition are not working as intended
- What does ‘**’ mean in C?
- Why use ++i instead of i++ in cases where the value is not used anywhere else in the statement?
- What does ‘return *this’ mean in C++?