Carray Nesting Problem. Error c2448; c2664; c2582

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.