There are no problems with the second version of the assignment operator. In fact, that is the standard way for an assignment operator.
Edit: Note that I am referring to the return type of the assignment operator, not to the implementation itself. As has been pointed out in comments, the implementation itself is another issue. See here.
Related Posts:
- What does the question mark character (‘?’) mean in C++?
- lvalue required as left operand of assignment – Array
- What does the question mark character (‘?’) mean in C++?
- Error while overloading operator (must be a nonstatic member function)
- error: ‘ostream’ does not name a type
- error: overloaded ‘operator<<' must be a binary operator (has 3 parameters)
- C++ operator+ and operator+= overloading
- operator << must take exactly one argument
- Operator Overloading C++; too many parameters for << operation
- How to use the PI constant in C++
- How to throw a C++ exception
- The static keyword and its various uses in C++
- What is the ‘override’ keyword in C++ used for? [duplicate]
- Unresolved external symbol in object files
- Mutex example / tutorial? [closed]
- “std::bad_alloc”: am I using too much memory?
- What does “dereferencing” a pointer mean?
- What is a smart pointer and when should I use one?
- check if a std::vector contains a certain object?
- Convert char to int in C and C++
- How to convert a char array to a string?
- How to fix a “invalid operands to binary expression” error?
- Is it possible to decompile a C++ executable file
- What does `*&` in a function declaration mean?
- (->) arrow operator and (.) dot operator , class pointer
- How to reverse an std::string? [duplicate]
- What is the C version of RMI
- Difference between ‘strcpy’ and ‘strcpy_s’?
- What is uintptr_t data type
- const int = int const?
- Undefined reference to vtable
- In C++, what is a virtual base class?
- “Multiple definition of” C++ compiler error
- What is the difference between a static and const variable?
- What is move semantics?
- Using “super” in C++
- unsigned int vs. size_t
- How do I clear a C++ array?
- error: expected primary-expression before ‘)’ token (C)
- What does -> mean in C++?
- What’s the difference between char and char* in C++?
- How to pass optional arguments to a method in C++?
- How to copy a string of std::string type in C++?
- C++ forbids variable-size array
- Fill array with random numbers within a specified range (C++)
- Remove an array element and shift the remaining ones
- Right way to split an std::string into a vector
- Enhanced FOR loops in C++
- string subscript out of range error
- push_back vs emplace_back
- No operator << matches these operands
- Returning an empty string : efficient way in c++
- How to find the size of an int[]?
- Append an int to a std::string
- Decimal to hex conversion c++ built-in function
- C++ IDE with repl?
- error: use of deleted function
- error: strcpy was not declared in this scope
- Difference between “or” and || in Ruby?
- how to print a string to console in c++
- How to call a parent class function from derived class function?
- How do I define string constants in C++?
- Error: No instance of constructor matches the argument list
- How can I get the list of files in a directory using C or C++?
- RPN Calculator for C++
- What does `Fatal Python error: PyThreadState_Get: no current thread` mean?
- Debug Assertion Failed: _CrtIsValidHeapPointer(block)
- gdb error not in executable format: File format not recognized
- C++ Erase vector element by value rather than by position?
- C++ Class ‘undeclared identifier”
- Destructor for Binary Search Tree
- What is the most popular general purpose C++ framework?
- C++ – include unistd.h: why not cunistd?
- Dynamically allocated string array, then change it’s value?
- Use the auto keyword in C++ STL
- c++ –
- C++ – statement cannot resolve address for overloaded function
- What’s the difference between * and & in C?
- is there is a compiler which convert c++ code into mips assembly language
- term does not evaluate to a function taking 1 arguments
- reading from stdin in c++
- Difference between pic Vs pie
- Stray ‘\342’ in C++ program
- gcc -g :what will happen
- QByteArray to QString
- Bitwise Less than or Equal to
- How to automatically convert strongly typed enum into int?
- Function cannot be referenced as it is a deleted function
- Difference between
and - How to get size of dynamic array in C++ [duplicate]
- Getting error “array bound is not an integer constant before ‘]’ token”
- Plotting graphs in C++
- Fatal error: iostream: No such file or directory in compiling C program using GCC
- error C2995: function template has already been defined
- Is there a way to compile C++ to C Code?
- enum to string in modern C++11 / C++14 / C++17 and future C++20
- Digit limitation from decimal point in C++
- error: expected unqualified-id before ‘while’|
- error C2039: ‘string’ : is not a member of ‘std’, header file problem
- “Cannot allocate an object of abstract type” error