Hi all,
I am trying to write a C++ program to create a simple text-based interface that should print out the relevant stubs when a certain choice is made. I am however getting linking errors such as-->[Linker error] undefined reference to `Database::AddStudent()' , that i cant seem to fix. Any help is greatly appreciated. I am using Dev-C++ 4.9.9.2 Please see my pieces of code below:-
Driver.cpp:
#include "Database.h"
#include <iostream>
#include <cstdlib>
using namespace std;
int main(int argc, char * argv[])
{
Database Data;
char k;
do
{
cout<<"Enter a number(0-7) or q to quit"<<endl;
cin >>k;
switch(k)
{
case'0':
Data.AddStudent();
break;
case'1':
Data.DeleteStudent();
break;
case'2':
Data.ReadDatabase();
break;
case'3':
Data.SaveDatabase();
break;
case'4':
Data.DisplayDetails();
break;
case'5':
Data.GradeStudent();
break;
case'6':
Data.DisplayAll();
break;
default:
std:: cout<<"Invalid entry!!"<<endl;
break;
}
}while(k!='q');
system("PAUSE");
return 0;
};
Database.cpp:
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include "Database.h"
using namespace std;
Database::Database()
{
cout << "Created TestClass\n";
}
Database::~Database() //Deconstructor
{
}
//Methods to do the required data manipulations
public:
void Database::AddStudent(void) //Enter new student data
{
cout<<"AddStudent() called"<<endl;
}
void DeleteStudent(void) //delete existing student record based on the given student number****
{
cout<<"DeleteStudent() called"<<endl;
}
void ReadDatabase(void) //read a simple text file which stores a list of database entries
{
cout<<"ReadDatabase() called"<<endl;
}
void SaveDatabase(void) //Write to a simple text file which stores a list of database entries
{
cout<<"SavaDatabase() called"<<endl;
}
void GradeStudent(void)//Print an average for a student based on a given student number. The average= number in the ClassRecord string and averaging
{
cout<<"GradeStudent() called"<<endl;
}
void DisplayDetails(void) //Print the record for a given student, based on the student number entered
{
cout<<"DisplayDetails() called"<<endl;
}
void DisplayAll(void) //Print records for all students in the database
{
cout<<"DisplayAll() called"<<endl;
}
Database.h:
#ifndef DATABASE_H
#define DATABASE_H
using namespace std;
class Database
{
public:
//Database();
virtual ~Database();
void AddStudent();
void DeleteStudent();
void ReadDatabase();
void SaveDatabase();
void GradeStudent();
void DisplayDetails();
void DisplayAll();
};
#endif