Linker error in dev c++!! ld returned 1 exit status..

the error shows:
[Linker error] undefined reference to `vtable for BASIC'
[Linker error] undefined reference to `vtable for BASIC'
ld returned 1 exit status
D:\Dev-Cpp\project\course\Makefile.win [Build Error] [course_des.exe] Error 1

I really don't know what's wrong with it:
here's my code:(3 parts:main.cpp;implement.cpp;headers.hpp)
by the way,anybody could tell me how to use the STL function "sort" in my own class "STU"??Coz' i've left a blank in the function "void sort_by_id()";
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>

#include "headers.hpp"

using namespace std;
int select_menu(){
    cout<<"************菜单************"
        <<"0.基本信息管理"
        <<"1.课程信息管理"
        <<"2.成绩信息管理"
        <<"3.退出系统"<<endl;
    int choice;
    do
    {cout<<"请选择0~3中的某一个选项:";
    cin>>choice;
    }while(choice<0||choice>3);
    return choice;
}
 
int main()
{
    int choose;
    BASIC_MANAGE obj1;
    /*for(;;){
            choose=select_menu();
            if(choose==0) BASIC_MANAGE *obj1=new BASIC_MANAGE;
            if(choose==1) COURSE_MANAGE *obj2=new COURSE_MANAGE;
            if(choose==2) SCORE_MANAGE *obj3=new SCORE_MANAGE;
            //switch(select_menu()){
            //case 0:break;
            //case 1://break;
            //case 2://break;
            //case 3:exit(0);
            //}
            }*/
    system("PAUSE");
    return 0;
}


implement.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include "headers.hpp"
#define COURSE_NUM 4
using namespace std;


bool BASIC::idcomp(STU *i,STU *j){
     return((i->id)<(j->id));}
bool BASIC::namecomp(STU *i,STU *j){
     return((i->name)<(j->name));}
int BASIC::check_password(){
     string p;
     int count=0;
     do{
     cout<<endl<<"Password:";
     cin>>p;
     if(count>0&&count<2) cout<<"Wrong Password!Please check again!";
     else if(count==2) cout<<"You have tried 3 times!Check failed!";
     }while(p!=pass&&count++<=2);
     if(count>=3) return 0;
     else {cout<<"Check Success!";return 1;}
     }
void BASIC::reset_password(){
     string re;
     if(check_password()==1)
     {cout<<endl<<"Please input new password:";
      cin>>re;
      pass=re;
      }
      }

void BASIC::search_by_id(){
     string temp_id;
     int count=0;
     cout<<"Please input id:";
     cin>>temp_id;
     for(vector<STU*>::iterator i=info.begin();i!=info.end();i++)
     {if((*i)->id==temp_id) {index=i;show();count++;}}
     if(count==0) cout<<"Record not found!"<<endl;
     }

void BASIC::search_by_name(){
     string temp_name;
     int count=0;
     cout<<"Please input name:";
     cin>>temp_name;
     for(vector<STU*>::iterator i=info.begin();i!=info.end();i++)
     {if((*i)->id==temp_name) {index=i;show();count++;}}
     if(count==0) cout<<"Record not found!"<<endl;
     }

void BASIC::sort_by_id(){
     //sort(info.begin(),info.end(),idcomp);
     }

void BASIC::sort_by_name(){
     //sort(info.begin(),info.end(),namecomp);
     }

int BASIC_MANAGE::select_menu(){
    cout<<"**********基本信息**********"
        <<"0.从文件读入"
        <<"1.增加一条记录"
        <<"2.按姓名查找"
        <<"3.按学号查找"
        <<"4.按姓名排序"
        <<"5.按学号排序"
        <<"6.修改记录"
        <<"7.删除记录" 
        <<"8.保存到文件"
        <<"9.显示全部记录"
        <<"10.退出" 
        <<endl;
    int choice;
    do
    {cout<<"请选择0~10中的某一个选项:";
    cin>>choice;
    }while(choice<0||choice>10);
    return choice;
}

BASIC_MANAGE::BASIC_MANAGE(){
     int c;
     while(c=select_menu(),c!=10){
     switch(c){
     case 0:read_from_file();break;
     case 1:add_record();break;
     case 2:search_by_name();break;
     case 3:search_by_id();break;
     case 4:sort_by_name();break;
     case 5:sort_by_id();break;
     case 6:search_by_id();modify();break;
     case 7:search_by_id();remove();break;
     case 8:save_to_file();break;
     case 9:show_all();break;
     }
     }
     if(c==10) cout<<"********退出基本信息管理*******"<<endl;
     }

void BASIC_MANAGE::read_from_file(){
     STU *temp=new STU;
     ifstream myfile;
     char url[10];
     cout<<"Please input URL:";
     cin>>url;
     myfile.open(url);
     if(myfile.is_open()){
     while(!myfile.eof()){
     myfile>>temp->name
           >>temp->id
           >>temp->age
           >>temp->sex
           >>temp->major
           >>temp->from;
     info.push_back(temp);
     }
     }
     }

void BASIC_MANAGE::add_record(){
     STU *temp=new STU;
     cout<<endl;
     cout<<" Name:";cin>>temp->name;
     cout<<"   ID:";cin>>temp->id;
     cout<<"  Age:";cin>>temp->age;
     cout<<"Major:";cin>>temp->major;
     cout<<" From:";cin>>temp->from;
     info.push_back(temp);
     }

void BASIC_MANAGE::remove_all(){
     if(check_password()) info.clear();
     }

void BASIC_MANAGE::save_to_file(){
     ofstream myfile;
     char url[10];
     cout<<"Please input URL:";
     cin>>url;
     myfile.open(url);
     if(myfile.is_open()){
     for(vector<STU*>::iterator i=info.begin();i!=info.end();i++)
     {myfile<<(*i)->name<<" "
            <<(*i)->id<<" "
            <<(*i)->age<<" "
            <<(*i)->major<<" "
            <<(*i)->from<<endl;
            }
            }
            }

void BASIC_MANAGE::show(){
     vector<STU*>::iterator rec=index;
     cout<<endl
         <<setw(10)<<(*rec)->name
         <<setw(10)<<(*rec)->id
         <<setw(10)<<(*rec)->age
         <<setw(10)<<(*rec)->major
         <<setw(10)<<(*rec)->from;
         }

void BASIC_MANAGE::show_all(){
     for(vector<STU*>::iterator i=info.begin();i!=info.end();i++)
     show();
     }

void BASIC_MANAGE::modify(){
     vector<STU*>::iterator rec=index;
     cout<<"Modify:"<<endl;
     cout<<" Name:";cin>>(*rec)->name;
     cout<<"   ID:";cin>>(*rec)->id;
     cout<<"  Age:";cin>>(*rec)->age;
     cout<<"Major:";cin>>(*rec)->major;
     cout<<" From:";cin>>(*rec)->from;
     }

void BASIC_MANAGE::remove(){
     vector<STU*>::iterator rec=index;
     char sure;
     cout<<"Remove record.Sure?";
     cin>>sure;
     if(sure=='y'||sure=='Y') info.erase(rec);
     }




headers.hpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

class STU{
      protected:
                string name;
                string id;
                int age;
                int sex;
                string major;
                string from;
                string courses[5];
                int score[5];
      friend class BASIC;
      friend class BASIC_MANAGE;
             };

class BASIC{
      protected:
      vector<STU*> info;
      vector<STU*>::iterator index;
      string pass;
      bool idcomp(STU *i,STU *j);
      bool namecomp(STU *i,STU *j);
      public:
             int check_password();
             void reset_password();
             virtual int select_menu()=0;
             virtual void read_from_file()=0;
             virtual void add_record()=0;
             virtual void remove_all()=0;
             virtual void save_to_file()=0;
             virtual void show()=0;
             virtual void show_all();
             virtual void modify()=0;
             virtual void remove()=0;
             void search_by_name();
             void search_by_id();
             void sort_by_id();
             void sort_by_name();
             };

class BASIC_MANAGE:public BASIC{
      public:
             BASIC_MANAGE();
             int select_menu();
             void read_from_file();
             void add_record();
             void remove_all();
             void save_to_file();
             void show();
             void show_all();
             void modify();
             void remove();
             };



thanks for your patience!!
Last edited on
So far all i've seen is that you have in the BASIC class a function called virtual void show_all(); which is not pure virtual but you have not defined a function called void BASIC::show_all() in the implementation file.
Cool!!I've solved it!
Thank you,Master!
Topic archived. No new replies allowed.