Results 1 to 6 of 6
  1. #1
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy

    Why am i getting these Link errors?

    Code:
    1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall mammal::mammal(void)" (??0mammal@@QAE@XZ) referenced in function "public: __thiscall dog::dog(void)" (??0dog@@QAE@XZ)
    1>main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall mammal::~mammal(void)" (??1mammal@@UAE@XZ) referenced in function "public: virtual __thiscall dog::~dog(void)" (??1dog@@UAE@XZ)
    [php]#include <iostream>
    using namespace std;
    class mammal
    {
    public:
    mammal(); //constructor
    virtual ~mammal(); //destructor
    virtual void speak() const { cout << "mammal\n"; }
    };



    class dog : public mammal
    {
    public:

    void speak() const { cout << "dog\n"; }
    };



    class human : public mammal
    {
    public:

    void speak() const { cout << "dog\n"; }
    };


    class bomberman : public mammal
    {
    public:

    void speak() const { cout << "Bomberman pwns \n"; }
    };[/php]


    [php]#include "classes.h"

    int main()
    {
    mammal *ptr;
    mammal *speak;
    startLoop:
    while(true)
    {
    char choice;
    cout << "(d)og (h)uman (b)omberman\n";
    cin >> choice;
    switch(choice)
    {
    case 'd':
    ptr = new dog;
    break;
    case 'h':
    ptr = new human;
    break;
    case 'b':
    ptr = new bomberman;
    break;
    case 'q':
    goto exit;
    default:
    cout << "not a choice, choose again\n";
    goto startLoop;
    }
    speak = ptr;
    speak->speak();
    }
    exit:
    return 0;
    }[/php]

    dont mind the gotos

  2. #2
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    You declared the constructor, you never did anything with it, why even add the constructor? Anyways, that's the reason, you declared it, and it's looking for the function to call, but you never declared what the function does.

    I really don't know how to explain it...

  3. The Following User Says Thank You to Void For This Useful Post:

    Auxilium (08-07-2010)

  4. #3
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Quote Originally Posted by Void View Post
    You declared the constructor, you never did anything with it, why even add the constructor? Anyways, that's the reason, you declared it, and it's looking for the function to call, but you never declared what the function does.
    ...i thought i need to declare the constructor anyways....
    oh well

  5. #4
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by Koreans View Post


    ...i thought i need to declare the constructor anyways....
    oh well
    Naww, if you're not going to take any default parameters just don't bother declaring the constructor.

  6. #5
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Roger that.
    Solved. Request close is request

  7. #6
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    ~solved and locked~
    Ah we-a blaze the fyah, make it bun dem!

Similar Threads

  1. How To get rid of all these .dll errors
    By TRacer in forum Combat Arms Help
    Replies: 4
    Last Post: 10-17-2010, 06:32 PM
  2. i get these error what should i do to fix it
    By hhhjr1 in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 15
    Last Post: 07-15-2010, 08:54 PM
  3. Why i keep getting this error?
    By muumimamma in forum Combat Arms EU Help
    Replies: 10
    Last Post: 07-03-2010, 10:19 PM
  4. D3D base error, Why im i getting this?
    By HazXoD3D in forum C++/C Programming
    Replies: 5
    Last Post: 10-15-2009, 11:05 AM
  5. [Help]I get these SYNTAX errors.Please Help
    By phoenixraider in forum C++/C Programming
    Replies: 2
    Last Post: 10-18-2008, 07:57 PM