When carray is nested, errors such as c2448, c2664, and c2582 may occur in many cases.
It also indicates an internal error of carray.
In kb231995, Microsoft described the problem and gave a brief description of the solution.
English version: http://support.microsoft.com/kb/231995/en
English Machine Translation: http://support.microsoft.com/kb/231995/zh-cn
There are two reasons for this.
1. for composite data structures (struct, class, etc.) without the value assignment operator (operate =), the compiler will automatically generate a default value assignment operator, which will enumerate all members of the data structure, then copy. Therefore, for a composite data structure containing carray, the default value assignment operator will copy carray's own data structure together.
2. carray inherits from cobject. For private members of cobject and carray, any copy request is rejected. (In fact, you should not copy carray itself, instead, copy the user data contained in carray. Generally, carray: copy can be used)
Therefore, the carray nesting will cause the above errors.
We recommend that you implement a copy constructor and a value assignment operator.
Example: Objective C ++
Class string {
Public:
String (const string & Str );
String & operate = (const string & Str );
}
The copy constructor can be implemented in a specific way, and the value assignment operator can be simply written as follows:
String: string (STR );
Return * this;
The assignment is implemented in a concise manner.