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. How to export the drived class from one abstract class? And also STL container is used as private members. [modified]

How to export the drived class from one abstract class? And also STL container is used as private members. [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicsdockerhelptutorial
14 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 SAMZCN

    In my case, I want to create one interface class and use it to employee the drived class implementation. The sample codes are as follows.

    CInterfaceClass
    {
    public:
    CInterfaceClass(){};
    virtual ~CInterfaceClass(){};
    virtual int Func1() = 0;
    virtual int Func2() = 0;
    virtual int Func3() = 0;
    }

    And the interface class will be used the DLL project and the client project. Here the drived class in the DLL project and it will be exported and be used by the client project:

    CMyDLLClass1 : public CInterfaceClass
    {
    public:
    CMyDLLClass1 (){};
    virtual ~ CMyDLLClass1 (){};
    virtual int Func1();
    virtual int Func2();
    virtual int Func3();
    private:
    vector<...> ....
    map<...> ....
    }

    And another DLL project may like this...

    CMyDLLClass2 : public CInterfaceClass
    {
    public:
    CMyDLLClass2 (){};
    virtual ~ CMyDLLClass2 (){};
    virtual int Func1();
    virtual int Func2();
    virtual int Func3();
    private:
    vector<...> ....
    map<...> ....
    }

    In the client project, I want to use the exported class like this.

    CInterfaceClass* pMyDllClass1 = new CMyDLLClass1();
    pMyDllClass1->Func1();
    pMyDllClass1->Func2();
    pMyDllClass1->Func3();
    CInterfaceClass* pMyDllClass2 = new CMyDLLClass2();
    pMyDllClass2->Func1();
    pMyDllClass2->Func2();
    pMyDllClass2->Func3();

    It seems that I can enter the functions. But many errors come out with STL members. I am confused on this usage of DLL. Could you pls give your help on this ?

    modified on Monday, November 22, 2010 7:57 PM

    CPalliniC Offline
    CPalliniC Offline
    CPallini
    wrote on last edited by
    #3

    It looks like you have problems with the STL library, not DLL issues. You should post the errors and (as Richard pointed out) the relevant code for getting better help. :)

    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
    [My articles]

    In testa che avete, signor di Ceprano?

    S 1 Reply Last reply
    0
    • S SAMZCN

      In my case, I want to create one interface class and use it to employee the drived class implementation. The sample codes are as follows.

      CInterfaceClass
      {
      public:
      CInterfaceClass(){};
      virtual ~CInterfaceClass(){};
      virtual int Func1() = 0;
      virtual int Func2() = 0;
      virtual int Func3() = 0;
      }

      And the interface class will be used the DLL project and the client project. Here the drived class in the DLL project and it will be exported and be used by the client project:

      CMyDLLClass1 : public CInterfaceClass
      {
      public:
      CMyDLLClass1 (){};
      virtual ~ CMyDLLClass1 (){};
      virtual int Func1();
      virtual int Func2();
      virtual int Func3();
      private:
      vector<...> ....
      map<...> ....
      }

      And another DLL project may like this...

      CMyDLLClass2 : public CInterfaceClass
      {
      public:
      CMyDLLClass2 (){};
      virtual ~ CMyDLLClass2 (){};
      virtual int Func1();
      virtual int Func2();
      virtual int Func3();
      private:
      vector<...> ....
      map<...> ....
      }

      In the client project, I want to use the exported class like this.

      CInterfaceClass* pMyDllClass1 = new CMyDLLClass1();
      pMyDllClass1->Func1();
      pMyDllClass1->Func2();
      pMyDllClass1->Func3();
      CInterfaceClass* pMyDllClass2 = new CMyDLLClass2();
      pMyDllClass2->Func1();
      pMyDllClass2->Func2();
      pMyDllClass2->Func3();

      It seems that I can enter the functions. But many errors come out with STL members. I am confused on this usage of DLL. Could you pls give your help on this ?

      modified on Monday, November 22, 2010 7:57 PM

      N Offline
      N Offline
      Nisamudheen
      wrote on last edited by
      #4

      In order to use the CInterfaceClass in another DLL, as a base class, you need to export this class first.

      S 1 Reply Last reply
      0
      • N Nisamudheen

        In order to use the CInterfaceClass in another DLL, as a base class, you need to export this class first.

        S Offline
        S Offline
        SAMZCN
        wrote on last edited by
        #5

        Really? I've make the interface class as one interface class with all functions of pure virtual property. It says it is an abstract class only. It seems not required to export it with the DLL's derived class. Right?

        Nisamudheen wrote:

        In order to use the CInterfaceClass in another DLL, as a base class, you need to export this class first.

        1 Reply Last reply
        0
        • L Lost User

          SAMZCN wrote:

          But many errors come out with STL members.

          Well we will have to guess what they are. It may be that you are not adding a using statement in your client project before the inclusion of the class containing the STL members. Alternatively you could add the full definitions in your headers like this:

          CMyDLLClass1 : public CInterfaceClass
          {
          public:
          CMyDLLClass1 (){};
          virtual ~ CMyDLLClass1 (){};
          virtual int Func1();
          virtual int Func2();
          virtual int Func3();
          private:
          std::vector<...> ....
          std::map<...> ....
          }

          Did you notice how I also used <pre></pre> tags to make the code snippet more readable?

          Just say 'NO' to evaluated arguments for diadic functions! Ash

          S Offline
          S Offline
          SAMZCN
          wrote on last edited by
          #6

          Hello Richard, Thanks for your input. I've include the headers in the DLL project

          #include #include #include #include using namespace std;

          Is ther any error on my implementation on the DLL exporting? Is it a right way to make DLL proj to export derived class like what I do ? It is the first time that I do it like this.

          Richard MacCutchan wrote:

          Well we will have to guess what they are. It may be that you are not adding a using statement in your client project before the inclusion of the class containing the STL members. Alternatively you could add the full definitions in your headers like this: CMyDLLClass1 : public CInterfaceClass { public: CMyDLLClass1 (){}; virtual ~ CMyDLLClass1 (){}; virtual int Func1(); virtual int Func2(); virtual int Func3(); private: std::vector<...> .... std::map<...> .... } Did you notice how I also used

          tags to make the code snippet more readable?

          L 1 Reply Last reply
          0
          • CPalliniC CPallini

            It looks like you have problems with the STL library, not DLL issues. You should post the errors and (as Richard pointed out) the relevant code for getting better help. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            S Offline
            S Offline
            SAMZCN
            wrote on last edited by
            #7

            Hi, Cpallini I am trying to find out some clue here... I am confused now... What's wrong with my code or proj? And the STL support headers are all included and employeed its namespace too.

            CPallini wrote:

            It looks like you have problems with the STL library, not DLL issues. You should post the errors and (as Richard pointed out) the relevant code for getting better help

            CPalliniC 1 Reply Last reply
            0
            • S SAMZCN

              Hi, Cpallini I am trying to find out some clue here... I am confused now... What's wrong with my code or proj? And the STL support headers are all included and employeed its namespace too.

              CPallini wrote:

              It looks like you have problems with the STL library, not DLL issues. You should post the errors and (as Richard pointed out) the relevant code for getting better help

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #8

              We can't just guess based on your description, we need facts code and error messages, Watson! :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              In testa che avete, signor di Ceprano?

              S 1 Reply Last reply
              0
              • S SAMZCN

                Hello Richard, Thanks for your input. I've include the headers in the DLL project

                #include #include #include #include using namespace std;

                Is ther any error on my implementation on the DLL exporting? Is it a right way to make DLL proj to export derived class like what I do ? It is the first time that I do it like this.

                Richard MacCutchan wrote:

                Well we will have to guess what they are. It may be that you are not adding a using statement in your client project before the inclusion of the class containing the STL members. Alternatively you could add the full definitions in your headers like this: CMyDLLClass1 : public CInterfaceClass { public: CMyDLLClass1 (){}; virtual ~ CMyDLLClass1 (){}; virtual int Func1(); virtual int Func2(); virtual int Func3(); private: std::vector<...> .... std::map<...> .... } Did you notice how I also used

                tags to make the code snippet more readable?

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

                This is fine but have you include all the correct headers (and reference to std namespace) in the class that is linking to the DLL, i.e the code that will be using the DLL. Remember that classes and methods exported from a DLL are visible to the linker not the compiler.

                Just say 'NO' to evaluated arguments for diadic functions! Ash

                S 1 Reply Last reply
                0
                • CPalliniC CPallini

                  We can't just guess based on your description, we need facts code and error messages, Watson! :)

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  S Offline
                  S Offline
                  SAMZCN
                  wrote on last edited by
                  #10

                  Oh... I am trying to catch the error. But I found it is uncertain and not repeatable.. :( Try to find more and report later ...

                  CPalliniC 1 Reply Last reply
                  0
                  • S SAMZCN

                    Oh... I am trying to catch the error. But I found it is uncertain and not repeatable.. :( Try to find more and report later ...

                    CPalliniC Offline
                    CPalliniC Offline
                    CPallini
                    wrote on last edited by
                    #11

                    What about the code & error message? :)

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    In testa che avete, signor di Ceprano?

                    1 Reply Last reply
                    0
                    • L Lost User

                      This is fine but have you include all the correct headers (and reference to std namespace) in the class that is linking to the DLL, i.e the code that will be using the DLL. Remember that classes and methods exported from a DLL are visible to the linker not the compiler.

                      Just say 'NO' to evaluated arguments for diadic functions! Ash

                      S Offline
                      S Offline
                      SAMZCN
                      wrote on last edited by
                      #12

                      Thanks. Yes. In the client project linking to the DLL, the client project include the DLL interface head file like this.

                      #include "MyExprotDllHead.h"

                      Now the issue is still pending. And so many new failure report and reported in STL allocation procedure. I'm trying my best to find out the root cause. :(

                      Richard MacCutchan wrote:

                      This is fine but have you include all the correct headers (and reference to std namespace) in the class that is linking to the DLL, i.e the code that will be using the DLL. Remember that classes and methods exported from a DLL are visible to the linker not the compiler.

                      L 1 Reply Last reply
                      0
                      • S SAMZCN

                        Thanks. Yes. In the client project linking to the DLL, the client project include the DLL interface head file like this.

                        #include "MyExprotDllHead.h"

                        Now the issue is still pending. And so many new failure report and reported in STL allocation procedure. I'm trying my best to find out the root cause. :(

                        Richard MacCutchan wrote:

                        This is fine but have you include all the correct headers (and reference to std namespace) in the class that is linking to the DLL, i.e the code that will be using the DLL. Remember that classes and methods exported from a DLL are visible to the linker not the compiler.

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

                        Fantastic! And what does that include file contain?

                        Just say 'NO' to evaluated arguments for diadic functions! Ash

                        S 1 Reply Last reply
                        0
                        • L Lost User

                          Fantastic! And what does that include file contain?

                          Just say 'NO' to evaluated arguments for diadic functions! Ash

                          S Offline
                          S Offline
                          SAMZCN
                          wrote on last edited by
                          #14

                          Include all the STL head files which are shared by the DLL and the client proj. And all the data structure of the DLL proj and all the data struct will be used by the cilent proj too. I'm trying ...

                          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