hey All.
I am currently working on a project to create a basic student registration system using classes and other sorts of stuff later on...
as of now, i am to create three classes as follows:
Person, Student, and courseInfo.
I have to create a simple driver program that allows the user to enter some basic information regarding a student. Such as first/last name, SSN, DOB, and more. After entering this data i need to be able to enter data such as course for this person, such as classID, semester, year, grade. So its pretty simple. I would like to create a menu system once i have the skeleton working...(something like:)
1. enter new student.
2. edit existing student.
3. edit course data for student (search via ID).
etc
As for now, my basic skeleton code looks like this:
//THIS SHOULD CONTAIN THE CLASS DEFINITION
#include "main.h"
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Person {
public:
Person(){};
virtual ~Person(){};
void infoPrint(string); //NEEDS FUNCTION DEFINITION
void setFirstName(string x){firstName = x;}
string getFirstName() const {return firstName;}
void setLastName(string x) {lastName = x;}
string getLastName() const {return lastName;}
void setSSN(string x) {SSN = x;}
string setSSN() const {return SSN;}
void setDOB(string x) {DOB = x;}
string getDOB() const {return DOB;}
void setGender(string x) {gender = x;}
string getGender() const {return gender;}
private:
string firstName;
string lastName;
string SSN;
string DOB;
string gender;
};
class Student : public Person {
public:
Student(){ZID = ""; };
virtual ~Student(){ZID = "";};
private:
string ZID;
typedef vector<string> courseInfoVec;
};
class CourseInfo {
public:
CourseInfo();
virtual ~CourseInfo();
private:
string courseID;
string yearTaken;
string semesterTaken;
string grade;
};
My little driver program contains:
#include "main.cpp"
int main()
{
Student NIU_Student;
string x;
cout << "Please enter the first name: ";
cin >> x;
NIU_Student.setFirstName(x);
cout << "Please enter the last name: ";
cin >> x;
NIU_Student.setLastName(x);
cout << "Please enter students social security number: ";
cin >> x;
NIU_Student.setSSN(x);
cout << "Please enter student DoB: ";
cin >> x;
NIU_Student.setDOB(x);
cout << "Please enter the student's gender: ";
cin >> x;
NIU_Student.setGender(x);
return 0;
}
But i currently get this error message:
[Linker error] undefined reference to `Student::Student()'
[Linker error] undefined reference to `Student::~Student()'
[Linker error] undefined reference to `Student::~Student()'
ld returned 1 exit status
My assumption is that is because i have not defined the constructor or the destructor correctly. But... i am unsure what i should have in each of those, as the strings i define don't need to be created before hand, the only thing i can think of is the space needed for the data... so i would have do something like:
vector<string> studentX = new vector<string>(firstName,lastName,...,....,.....);
is this somewhat correct in my logic? Please explain if otherwise?
thank you all