2
// Example program
#include <iostream>
#include <string>

using namespace std;

class table
{
    int size;
    int priority;

    public:
    table(int s=0, int p=0):size(s),priority(p){}
    virtual void print();
};

class stud_table: public table
{
    char *name;
    int gr;

    public:
        void print(){ cout <<"students table"<<endl; }
        ~stud_table(){ delete []name; }
};

class asp_table: public table
{
    char *thesis;
};


int main()
{
  table t;
  stud_table st;
  table *tp=&st;

  tp = new asp_table();
  stud_table *stp = &st;

  cout << "Program" << endl;
  return 0;
}

/* Why I get link errors: Error 2 error LNK1120: 1 unresolved externals

Error 1 error LNK2001: unresolved external symbol "public: virtual void __thiscall table::print(void)" (?print@table@@UAEXXZ)

*/

user3879626
  • 127
  • 6
  • @πάνταῥεῖ I don't think it's a simple duplicated question. It seems to be a bug of the complier what op used, [clang](http://rextester.com/RDFD88926) runs it well. – songyuanyao Jan 09 '16 at 10:48

1 Answers1

0

The error message is enough clear: member function print in class table is declared but not defined.

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335