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. problem in this little eg

problem in this little eg

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
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.
  • A Offline
    A Offline
    aesthetic crazy
    wrote on last edited by
    #1

    plz somebody tell me whats the problem with this little example? i get an error Error 1 error LNK2019: unresolved external symbol "public: __thiscall B::B(void)" (??0B@@QAE@XZ) referenced in function _main #include <iostream> using namespace std; class A { public: A(); ~A(); }; class B : public A { public: B(); ~B(); }; int main() { A *p; p = new B; // ... delete p; }

    CPalliniC 1 Reply Last reply
    0
    • A aesthetic crazy

      plz somebody tell me whats the problem with this little example? i get an error Error 1 error LNK2019: unresolved external symbol "public: __thiscall B::B(void)" (??0B@@QAE@XZ) referenced in function _main #include <iostream> using namespace std; class A { public: A(); ~A(); }; class B : public A { public: B(); ~B(); }; int main() { A *p; p = new B; // ... delete p; }

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

      If you declare the default constructors A::A() and B::B() then you must provide an implementation as well (the same applies to the destructors A::~A() B::~B()). Hence you either write:

      class A
      {
      };
      class B : public A
      {
      };

      or

      class A
      {
      public:
      A(){}
      ~A(){}
      };
      class B : public A
      {
      public:
      B(){}
      ~B(){}
      };

      :)

      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
      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