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. C / C++ / MFC
  4. Derived class from abstract class(COleControl in MFC) gave error while allocation memory

Derived class from abstract class(COleControl in MFC) gave error while allocation memory

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpvisual-studioperformancehelp
2 Posts 2 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.
  • D Offline
    D Offline
    dashprasannajit
    wrote on last edited by
    #1

    Created a class i.e. CFlipCustomViewer derived from COleConrol class(abstact class)and overridden the "virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)" method of COleControl class in the void CFlipCustomViewer::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid).I tried to call this in OnInitDialog() method of my dialog class of the application.Here the code snippets.. BOOL CFlip::OnInitDialog() { //having a CStatic as a place holder and then //create the flip custom control in InitDialog COleControl* ptrOleControl; //abstract base class pointer CFlipCustomViewer* ptrFlipCustomViewer; //derived class pointer ptrOleControl = ptrFlipCustomViewer; //derived class pointer assigned to abstract base class pointer ptrOleControl = new CFlipCustomViewer(); //error in this instantiation of derived one CDC* pdc = GetDC(); //get the device context CRect rcBounds; CRect rcInvalid; GetClientRect( &rcBounds); GetClientRect( &rcInvalid); ptrOleControl->OnDraw(pdc,rcBounds,rcInvalid);//place holder for flipping action CDialog::OnInitDialog(); return TRUE; } **************************************************************************************** but while compiling i am getting the following errors as below : error C2259: 'CFlipCustomViewer' : cannot instantiate abstract class due to following members: d:\fancyviewer\flipsample\flipcustomviewer.h(14) : see declaration of 'CFlipCustomViewer' d:\fancyviewer\flipsample\flip.cpp(200) : warning C4259: 'long __thiscall COleControl::GetClassID(struct _GUID *)' : pure virtual function was not defined d:\program files\microsoft visual studio\vc98\mfc\include\afxctl.h(683) : see declaration of 'GetClassID' d:\fancyviewer\flipsample\flip.cpp(200) : warning C4259: 'unsigned int __thiscall COleControl::GetUserTypeNameID(void)' : pure virtual function was not defined d:\program files\microsoft visual studio\vc98\mfc\include\afxctl.h(936) : see declaration of 'GetUserTypeNameID' d:\fancyviewer\flipsample\flip.cpp(200) : warning C4259: 'unsigned long __thiscall COleControl::GetMiscStatus(void)' : pure virtual function was not defined d:\program files\microsoft visual studio\vc98\mfc\include\afxctl.h(937) : see declaration of 'GetMiscStatus' d:\fancyviewer\flipsample\flip.cpp(200) : error C2259: 'CFlipCustomViewer' : cannot instantiate abstract class due to following members: d:\fancyviewer\flipsample\flipcustomviewer.h(14) :

    Steve EcholsS 1 Reply Last reply
    0
    • D dashprasannajit

      Created a class i.e. CFlipCustomViewer derived from COleConrol class(abstact class)and overridden the "virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)" method of COleControl class in the void CFlipCustomViewer::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid).I tried to call this in OnInitDialog() method of my dialog class of the application.Here the code snippets.. BOOL CFlip::OnInitDialog() { //having a CStatic as a place holder and then //create the flip custom control in InitDialog COleControl* ptrOleControl; //abstract base class pointer CFlipCustomViewer* ptrFlipCustomViewer; //derived class pointer ptrOleControl = ptrFlipCustomViewer; //derived class pointer assigned to abstract base class pointer ptrOleControl = new CFlipCustomViewer(); //error in this instantiation of derived one CDC* pdc = GetDC(); //get the device context CRect rcBounds; CRect rcInvalid; GetClientRect( &rcBounds); GetClientRect( &rcInvalid); ptrOleControl->OnDraw(pdc,rcBounds,rcInvalid);//place holder for flipping action CDialog::OnInitDialog(); return TRUE; } **************************************************************************************** but while compiling i am getting the following errors as below : error C2259: 'CFlipCustomViewer' : cannot instantiate abstract class due to following members: d:\fancyviewer\flipsample\flipcustomviewer.h(14) : see declaration of 'CFlipCustomViewer' d:\fancyviewer\flipsample\flip.cpp(200) : warning C4259: 'long __thiscall COleControl::GetClassID(struct _GUID *)' : pure virtual function was not defined d:\program files\microsoft visual studio\vc98\mfc\include\afxctl.h(683) : see declaration of 'GetClassID' d:\fancyviewer\flipsample\flip.cpp(200) : warning C4259: 'unsigned int __thiscall COleControl::GetUserTypeNameID(void)' : pure virtual function was not defined d:\program files\microsoft visual studio\vc98\mfc\include\afxctl.h(936) : see declaration of 'GetUserTypeNameID' d:\fancyviewer\flipsample\flip.cpp(200) : warning C4259: 'unsigned long __thiscall COleControl::GetMiscStatus(void)' : pure virtual function was not defined d:\program files\microsoft visual studio\vc98\mfc\include\afxctl.h(937) : see declaration of 'GetMiscStatus' d:\fancyviewer\flipsample\flip.cpp(200) : error C2259: 'CFlipCustomViewer' : cannot instantiate abstract class due to following members: d:\fancyviewer\flipsample\flipcustomviewer.h(14) :

      Steve EcholsS Offline
      Steve EcholsS Offline
      Steve Echols
      wrote on last edited by
      #2

      You need to override all the pure virtual functions of an abstract base class, but why not just derive from from CWnd instead?


      - S 50 cups of coffee and you know it's on!

      • S
        50 cups of coffee and you know it's on!
        Code, follow, or get out of the way.
      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