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. Abstract class as interface

Abstract class as interface

Scheduled Pinned Locked Moved C / C++ / MFC
c++designhelptutorialquestion
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.
  • S Offline
    S Offline
    s o v a n n
    wrote on last edited by
    #1

    Hi! I am writing a custom window control in MFC: a tab control.

    CWnd
    A
    |
    |
    MyTab

    class MyTab : protected CWnd {
    public:
    void add(const CString& title, CDialog* dlg);
    ...
    protected:
    ...
    private:
    ...
    };

    Everything goes well. Now I want to seperate interfaces from implementation theorically:

    CWnd ITab (abstract class as interface)
    A A
    | /
    | /
    MyTab

    class ITab {
    public:
    virtual void add(const CString& title, CDialog* dlg)=0;
    };

    class MyTab : public ITab, protected CWnd {
    public:
    virtual void add(const CString& title, CDialog* dlg);
    ...
    protected:
    ...
    private:
    ...
    };

    This time, the problem exist: there is no HWND attached. Does anyone know how to solve this? Or is there an alternative design? Any reply would be appreciated. sovann. Why waste time learning while ignorence is instantaneous ? [Hobbes]

    R 1 Reply Last reply
    0
    • S s o v a n n

      Hi! I am writing a custom window control in MFC: a tab control.

      CWnd
      A
      |
      |
      MyTab

      class MyTab : protected CWnd {
      public:
      void add(const CString& title, CDialog* dlg);
      ...
      protected:
      ...
      private:
      ...
      };

      Everything goes well. Now I want to seperate interfaces from implementation theorically:

      CWnd ITab (abstract class as interface)
      A A
      | /
      | /
      MyTab

      class ITab {
      public:
      virtual void add(const CString& title, CDialog* dlg)=0;
      };

      class MyTab : public ITab, protected CWnd {
      public:
      virtual void add(const CString& title, CDialog* dlg);
      ...
      protected:
      ...
      private:
      ...
      };

      This time, the problem exist: there is no HWND attached. Does anyone know how to solve this? Or is there an alternative design? Any reply would be appreciated. sovann. Why waste time learning while ignorence is instantaneous ? [Hobbes]

      R Offline
      R Offline
      Roman Fadeyev
      wrote on last edited by
      #2

      Sovann wrote: This time, the problem exist: there is no HWND attached. I have not understood what it means (hwnd of what???), but I want to give you small advice: mfc classes must be first at deriving order (MSDN says that). Swap 'public ITab' and 'protected CWnd', otherwise you will have a problems

      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