How can I display the instantiation of the COM class created with ATL?

Source: Internet
Author: User

See
Http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20513227.html

Use ATL to add an "ATL simple object" called myobject
In this case, I want to create a new myobject * PTR = new myobject ();)
The following error occurs during compilation: "error c2259 cannot instantiate abstract class ."

The answer here is the feature of pure virtual functions. I think it should be a feature of ATL. I think this is the correct answer:

Comment from yuriputivsky
Date: 02/13/2003 0:57 pm PST
Comment  
This is a well-known ATL trick.
The right way to create the instance of ATL class is:

Ccomclass <yuor_class_name> * pobj = 0;
Hresult hR = ccomclass <yuor_class_name>: createinstanCe (& pobj );
// Check error here
// Also the good practice to request some interface through QueryInterface function because some internal static data are finally initialized on QueryInterface.

Change ccomclass to ccomobject.

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.