How to Use coblist in MFC

Source: Internet
Author: User

In MFC, variables defined by the coblist type can be used to store class objects, but these variables must inherit the cobject class. Because coblist stores the pointer of the cobject class object.

Example: coblist list [num];

When retrieving the elements in the list, the pointer is taken. You need to convert the cobject type pointer to the following type:

Plan * OPLAN = (Plan *) List-> gethead (); // pointer type conversion

The following are incorrect practices:

Plan OPLAN = (Plan) * List-> gethead (); // type conversion

Or

Plan * OPLAN = List-> gethead (); // type conversion

A similar error occurs:

Error c2440: 'initializing': cannot convert from 'class cobject * 'to 'class plan *'

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.