Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Cannot instantiate abstract class due to following members

Cannot instantiate abstract class due to following members

Scheduled Pinned Locked Moved COM
helpc++comquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shadi Al Kahwaji
    wrote on last edited by
    #1

    Hi all, Please, can I find somebody to help me in this problem, I'm using a custom made ATL component, I have the .h and .c, and I have put some create instance statments in my COM Client, but always I face this compile error on each create instance command : error C2259: 'CMyClass' : cannot instantiate abstract class due to following members: warning C4259: 'long __stdcall IUnknown::QueryInterface(const struct _GUID &,void ** )' : pure virtual function was not defined Anybody can help in this problem? :( Yours, ShadiK. Shadi Al-Kahwaji

    M M L 3 Replies Last reply
    0
    • S Shadi Al Kahwaji

      Hi all, Please, can I find somebody to help me in this problem, I'm using a custom made ATL component, I have the .h and .c, and I have put some create instance statments in my COM Client, but always I face this compile error on each create instance command : error C2259: 'CMyClass' : cannot instantiate abstract class due to following members: warning C4259: 'long __stdcall IUnknown::QueryInterface(const struct _GUID &,void ** )' : pure virtual function was not defined Anybody can help in this problem? :( Yours, ShadiK. Shadi Al-Kahwaji

      M Offline
      M Offline
      Michael P Butler
      wrote on last edited by
      #2

      What does your CreateInstance code look like? The error is saying that your class hasn't implemented the IUnknown methods, QueryInterface, AddRef etc. However if you are trying to create a instance this shouldn't be happening as your COM DLL should have the implementation. Are you using smart pointers, #import or using CoCreateInstance? Michael :-)

      S 1 Reply Last reply
      0
      • M Michael P Butler

        What does your CreateInstance code look like? The error is saying that your class hasn't implemented the IUnknown methods, QueryInterface, AddRef etc. However if you are trying to create a instance this shouldn't be happening as your COM DLL should have the implementation. Are you using smart pointers, #import or using CoCreateInstance? Michael :-)

        S Offline
        S Offline
        Shadi Al Kahwaji
        wrote on last edited by
        #3

        Hi, First thank you for your reply. Actually I'm using a ready made component which I don't know anything about how does it implemented, but I have the component.h and component_i.c files, and I'm linking to the component using these two files and the ofcourse the .DLL itself. No #import, no smart pointers, just CoCreateInstance which directly creates the required interfaces, and on those CoCreateInstance statement I have this error. Regards, ShadiK. Shadi Al-Kahwaji

        M 1 Reply Last reply
        0
        • S Shadi Al Kahwaji

          Hi all, Please, can I find somebody to help me in this problem, I'm using a custom made ATL component, I have the .h and .c, and I have put some create instance statments in my COM Client, but always I face this compile error on each create instance command : error C2259: 'CMyClass' : cannot instantiate abstract class due to following members: warning C4259: 'long __stdcall IUnknown::QueryInterface(const struct _GUID &,void ** )' : pure virtual function was not defined Anybody can help in this problem? :( Yours, ShadiK. Shadi Al-Kahwaji

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          Can you post some of the problematic code? Usually that error happens when you try to use use new to create an ATL class, which is the wrong way to do it, but you said you're using CreateInstance. Does the class have a BEGIN_COM_MAP()/END_COM_MAP() section? --Mike-- http://home.inreach.com/mdunn/ :love: your :bob: with :vegemite: and :beer:

          1 Reply Last reply
          0
          • S Shadi Al Kahwaji

            Hi, First thank you for your reply. Actually I'm using a ready made component which I don't know anything about how does it implemented, but I have the component.h and component_i.c files, and I'm linking to the component using these two files and the ofcourse the .DLL itself. No #import, no smart pointers, just CoCreateInstance which directly creates the required interfaces, and on those CoCreateInstance statement I have this error. Regards, ShadiK. Shadi Al-Kahwaji

            M Offline
            M Offline
            Michael P Butler
            wrote on last edited by
            #5

            I need to see the CoCreateInstance code fragment to help more. It seems like you are trying to create the c++ class instead of the interface. Michael :-)

            1 Reply Last reply
            0
            • S Shadi Al Kahwaji

              Hi all, Please, can I find somebody to help me in this problem, I'm using a custom made ATL component, I have the .h and .c, and I have put some create instance statments in my COM Client, but always I face this compile error on each create instance command : error C2259: 'CMyClass' : cannot instantiate abstract class due to following members: warning C4259: 'long __stdcall IUnknown::QueryInterface(const struct _GUID &,void ** )' : pure virtual function was not defined Anybody can help in this problem? :( Yours, ShadiK. Shadi Al-Kahwaji

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Sound similar to an error I have made when initially typing code. Many times I do not declare the pointer to the COM object as a pointer and it gives the error you state. THis is correct: IXMLDOMDocument *pXML = NULL; hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument2, (void**)&pXML); // Check the return value, hr... ASSERT(SUCCEEDED(hr) && pXML!=NULL); This is not: IXMLDOMDocument pXML = NULL; << this line produces the error not the next! hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument2, (void**)&pXML); // Check the return value, hr... ASSERT(SUCCEEDED(hr) && pXML!=NULL); Michael A Barnhart mabtech@swbell.net

              S 1 Reply Last reply
              0
              • L Lost User

                Sound similar to an error I have made when initially typing code. Many times I do not declare the pointer to the COM object as a pointer and it gives the error you state. THis is correct: IXMLDOMDocument *pXML = NULL; hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument2, (void**)&pXML); // Check the return value, hr... ASSERT(SUCCEEDED(hr) && pXML!=NULL); This is not: IXMLDOMDocument pXML = NULL; << this line produces the error not the next! hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument2, (void**)&pXML); // Check the return value, hr... ASSERT(SUCCEEDED(hr) && pXML!=NULL); Michael A Barnhart mabtech@swbell.net

                S Offline
                S Offline
                Shadi Al Kahwaji
                wrote on last edited by
                #7

                Thank you sir. And I would like to thank everybody tried to help me. The problem is that I was trying to use the COM component as a smart pointers, but there were not.:laugh: Thank you all again. Shadi Al-Kahwaji

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups