Home > Back-end >  The assignment operator overloading problem
The assignment operator overloading problem

Time:02-07

I define a structure array

To achieve such operations

So overloaded=


Can be found in
,1,3,4,51,12,5,6 line_Arry _first={2};
When this sentence to a syntax error

If direct use array assignment also can appear type mismatch
I want to ask is

1. If operator overloading parameter type you can't change?
2. If 1 is correct, why the above operator=you can compile success? The compiler is no inspection on this? Or have other USES?
3. The implementation of this operation is there any way?

CodePudding user response:

{1, 2, 3} that does not mean that is an array, c + + 11 after he is initializer_list, can use it to initialize an array, but he can't directly into the array.
C + + 11 before he called initialization list, but it is not an array of

If you are with the support of the c + + 11 compiler

Operator=(const initializer_list & lt; Int> & O)
Way to initialize the

CodePudding user response:

reference 1/f, the truth is right or wrong response:
{1, 2, 3} that does not mean that is an array, c + + 11 after he is initializer_list, can use it to initialize an array, but he can't directly into the array.
C + + 11 before he called initialization list, but it is not an array of

If you are with the support of the c + + 11 compiler

Operator=(const initializer_list & lt; Int> & O)
Way to initialize

To study the
  • Related