Error code LNK2019 [duplicate] - c++

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 5 years ago.
I need help debugging this code for a class. I am not a computer science major, so I need explanation in very basic terms. The error code I'm getting is error LNK2019: unresolved external symbol "public: void __thiscall Student::showStudent(void)" (?showStudent#Student##QAEXXZ) referenced in function _main
I don't understand what this means. Can someone explain please?
#include<iostream>
#include<string.h>
using namespace std;
//Added namespace
class Person
{
public:
char initial;
Person(const int id, const int a, const char i);
//Renamed function Person
void showPerson();
int idNum;
int age;
};
Person::Person(const int id, const int a, const char i)
{
idNum = id;
age = a;
initial = i;
};
void Person::showPerson(void)
{
cout << "Person id#: " << idNum << " Age: " << age << " Initial: " << initial;
//Added << to the correct places
}
class Student
{
public:
Student (const int id, const int a, const char i, const double gpa);
void showStudent();
double gpa;
int idNum;
int age;
char initial;
};
Student::Student(const int id, const int a, const char i, const double gradePoint)
{
Person::Person(id, a, i);
gpa = gradePoint;
};
void showStudent(Student student)
{
cout << "Student ID# " << student.idNum;
cout << " Avg: " << student.gpa << endl;
cout << "Person id#: " << student.idNum << " Age: " << student.age << " Initial: " << student.initial;
cout << endl << " Age: " << student.age << ".";
cout << " Initial: " << student.initial << endl;
};
void main()
{
Person per(387, 23, 'A');
//Put two lines into one
cout << endl << "Person..." << endl;
per.showPerson();
Student stu(388, 18, 'B', 3.8);
cout << endl << endl << "Student..." << endl;
stu.showStudent();
system("pause");
}
It's giving me a LNK2019 error? Help please!

Adding to AndyG's answer. Your Student class should inherit from Person. Like so:
class Student : public Person {
/* members */
};
Because in your Student constructor you're calling Person::Person(id, a, i); and this will not set your Student attributes idNum, age and initial, because you've redefined them in Student and you're calling the Person ctor without initialising it to anything.
To make your code more cohesive and reusable I would define the classes like this:
class Person {
protected:
char initial;
int idNum;
int age;
public:
Person(const int id, const int a, const char i);
void showPerson();
};
class Student : public Person {
private:
double gpa;
public:
Student (const int id, const int a, const char i, const double gpa);
void showStudent();
};
In this way your Student instances have all of the protected member attributes (id, age and initial) from the Person class and this defines a Student is a Person. This is part of Object Oriented Programming (OOP) paradigm.
So you set your Student constructor like this:
Student::Student(const int& id, const int& a, const char& i, const double& gradePoint) {
idNum = id; // This works because Student inherits from Person, so it has all its attributes!
age = a;
initial = i;
gpa = gradePoint;
};
And now you shouldn't have errors and you have a clean, reusable OOP solution at hand. You could now, for instance, have a Teacher which also inherits (is a generalisation of) from Person and it will have Person's attributes.

Related

How do I use have a constructor with another class object in c++?

I've got a simple program where I have two classes which are Hat and Person. Each Person has a string name, a int idNum and a hat object. Each hat simply has a string of hatType and a char of hatSize. In the main method I want to simply declare 2 people and use a display method to show the information. Here's my current code, please go easy on me I'm still new to OOP in c++.
Person Class
class Person
{
private:
string name;
unsigned int idNum;
Hat myHat;
public:
Person(string, unsigned int, Hat);
void display();
};
Person::Person(string personName, unsigned int personID)
{
name = personName;
idNum = personID;
myHat = hat;
}
void Person::display()
{
cout << "Given name : " << name << endl;
cout << "Id. number : " << idNum << endl;
hat.display();
}
Hat Class
class Hat
{
private:
string hatType;
char hatSize; // S, M, L
public:
Hat(string,char);
void display();
};
Hat::Hat(string _type, char _size){
hatType = _type;
hatSize = _size;
}
void Hat::display()
{
cout << "Hat type : " << hatType << endl;
cout << "Hat size : " << hatSize << endl;
}
Main
int main()
{
Person personA("Alice",12321, Hat("Trilbee",'M'));
Person personB("Bob",2324, Hat("Ferret",'S'));
personA.display();
personB.display();
return 0;
}
your Person class here:
Person::Person(string personName, unsigned int personID)
{
. ...
is not fully implemented just add the hat parameter...
Person::Person(string personName, unsigned int personID, Hat hat)
{....
Below is the complete corrected(working) version. I have added some comments to show the changes i made.
#include <iostream>
#include <string>
using namespace std;
class Hat
{
private:
string hatType;
char hatSize; // S, M, L
public:
Hat(string,char);
//Added this default constructor since it won't be synthesized automatically
Hat()
{
std::cout<<"Default constructor"<<std::endl;
}
void display();
};
Hat::Hat(string _type, char _size){
hatType = _type;
hatSize = _size;
}
void Hat::display()
{
cout << "Hat type : " << hatType << endl;
cout << "Hat size : " << hatSize << endl;
}
class Person
{
private:
string name;
unsigned int idNum;
Hat myHat;
public:
Person(string, unsigned int, Hat);
void display();
};
//added the 3rd parameter of type Hat
Person::Person(string personName, unsigned int personID, Hat hat)
{
name = personName;
idNum = personID;
myHat = hat;
}
void Person::display()
{
cout << "Given name : " << name << endl;
cout << "Id. number : " << idNum << endl;
myHat.display();//changed hat.display() to myHat.display();
}
int main()
{
Person personA("Alice",12321, Hat("Trilbee",'M'));
Person personB("Bob",2324, Hat("Ferret",'S'));
personA.display();
personB.display();
return 0;
}

c++ inheritance problem and pointers. Trying to access child class with a pointer but the function is not being able to be found

So I am coding in c++ and am having a problem with inheritance and pointers. I am trying to access how many notches are in the gun slinger object (gun) but it is saying person has no such function. gun is a child class of person so I am a bit confused. here is the code
side note the error is p->getnotches() in main and it says (class "Person" has no member "getnotches")
int main()
{
Person *p;
Gunslinger gun("Doc Holiday", 5);
//PokerPlayer poker("Billy Jack");
//BadDude bad("Billy Kid", 4);
Person p1("James Cagney");
cout << "Persons name is: " << p1.getName() << endl;
Person p2 = p1;
Person p3, p4;
p4 = p3 = p1;
p = new Person("Jack Benny");
cout << "Person name is: " << p->getName() << endl;
cout << "Person 1 name is: " << p1.getName() << endl;
cout << "Person 2 name is: " << p2.getName() << endl;
cout << "Person 3 name is: " << p3.getName() << endl;
cout << "Person 4 name is: " << p4.getName() << endl;
delete p;
p = &gun;
cout << "Gunslinger name: " << p->getName() << " and number of notched on gun is: " <<
p->getnotches() << endl;
return 0;
}
#ifndef PERSON_H
#define PERSON_H
#pragma once
#include <iostream>
#include <string>
using namespace std;
class Person
{
private:
char *name;
public:
Person();
Person(string name);
virtual string getName();
virtual ~Person();
};
#endif
// no default constructor
Person::Person()
{
}
// this function assigns a name to person object
Person::Person(string n)
{
name = new char[n.length() + 1];
strcpy(name, n.c_str());
}
// this functions grabs the name of the person object
string Person::getName()
{
return name;
}
Person::~Person()
{
delete[] name;
}
#ifndef GUNSLINGER_H
#define GUNSLINGER_H
#pragma once
#include "Person.hpp"
#include <cstring>
#include <string>
class Gunslinger : public Person
{
private:
char *name;
int notches;
double drawTime;
public:
Gunslinger(string n, int cylinders);
int getnotches();
virtual string getName();
~Gunslinger();
};
#endif
#include "Gunslinger.hpp"
Gunslinger::Gunslinger(string n, int clinders)
{
name = new char[n.length() + 1];
strcpy(name, n.c_str());
notches = clinders;
}
string Gunslinger::getName()
{
return name;
}
int Gunslinger::getnotches()
{
return notches;
}
Gunslinger::~Gunslinger()
{
delete[] name;
}
In this expression
p->getnotches()
the static type of the pointer p is Person * due to this declaration
Person *p;
So the compiler searches in the class Person the function getnotches and does not find it because the class does not have such a function.
class Person
{
private:
char *name;
public:
Person();
Person(string name);
virtual string getName();
virtual ~Person();
};
You need to use dynamic_cast (if the compiler supports it) or reinterpret_cast with the pointer.
Although you have a Gunslinger object, you're treating it as a Person object and the Person class does not have a getnotches method. I'm not sure why you want to have a Person* to a Gunslinger object. Just use the Gunslinger 'gun' instead of the Person* 'p'.
cout << "Gunslinger name: " << gun.getName() << " and number of notched on gun is: " <<
gun.getnotches() << endl;

My char array in my c++ program will not print anything

I am doing my first C++ program for my class. I am really new to this program so I have a lot to learn. In my program I am suppose to create a Student class with Undergrad/grad/gradassist derived classes. The name and SSN fields have to be in a char array (I know string makes more sense but the teacher demands a char array). The program mostly works fine except it does not print anything in my char arrays. Please help!
#include <iostream>;
using namespace std;
class Student {
protected:
char name[21];
char ssn[10];
float gpa;
int credits;
public:
Student::Student() {};
Student(const char n[], const char ss[], float& gp, int& cred) {
name[21] = n[21];
ssn[10] = ss[10];
gpa = gp;
credits = cred;
}
virtual void print() {
cout << "Name: " << name << endl;
cout << "SSN: " << ssn << endl;
cout << "GPA: " << gpa << endl;
cout << "Credits: " << credits << endl;
}
virtual float tuition() const = 0;
};
class undergrad : public Student {
protected:
float undergrad_rate;
char* year;
public:
undergrad::undergrad() {}
undergrad(float ugr, char* yr, const char n[], const char ss[], float&
gp, int& cred) :
Student(n, ss, gp, cred), undergrad_rate(ugr), year(yr){}
void set_year(char* yr) {
year = yr;
}
char* getYear() {
return year;
}
float getRate() {
return undergrad_rate;
}
void print() {
Student::print();
cout << "Undergrad rate: " << undergrad_rate << endl;
cout << "year: " << year << endl;
}
float tuition() {
//cout << "The tuition is $35000" << endl;
return 35000;
}
};
class grad : public Student {
protected:
float grad_rate;
char* thesis;
public:
};
int main(){
char* jr = "Junior";
char* sr1 = "Senior";
char* fr = "Freshman";
char* sr = "Sophmore";
undergrad g(380, jr, "M", "000111222", 4.0, 12);
g.print();
system("pause");
return 0;
}
The problem lies here, in the way you initialize the members name and ssn:
Student(const char n[], const char ss[], float& gp, int& cred) {
name[21] = n[21];
ssn[10] = ss[10];
There's more than one thing wrong here
name and ssn are char arrays of size 21 and size 10 respectively. This means that valid indices range from 0 to 20 and 0 to 9 respectively. So by accessing name[21] and ssn[10] you're accessing elements past the end of the allotted memory.
Even if the indices were valid, you would just be assigning a single character by doing it this way.
In order to initialize these member variables the way you're intending, do this:
Student(const char n[], const char ss[], float& gp, int& cred) {
strcpy_s(name, sizeof(name), n);
strcpy_s(ssn, sizeof(ssn), ss);
This will copy all the characters comprising the input strings into your member variables and you will get the desired output.

My output is not correct when displayed

My output name is not being displayed in my program. I have been looking at the code and
I just can't find my error
input
name : John Dough
id : 123445
start date : 10312014
shift: 2
output
name : ^^^^^^ <<<< I am having problem my name not being displayed
id : 123445
start date : 10312014
shift : 2
code
//This program demostrates a class and a derived class with constructors.
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class Employee
{
private:
char EmpName;
int EmpNum;
int HireDate;
public:
void setEmpName(char);
void setEmpNum(int);
void setHireDate(int);
char getEmpName() const;
int getEmpNum() const;
int getHireDate() const;
Employee();
};
void Employee::setEmpName(char x)
{
EmpName = x;
}
void Employee::setEmpNum(int y)
{
EmpNum = y;
}
void Employee::setHireDate(int z)
{
HireDate = z;
}
char Employee::getEmpName() const
{
return EmpName;
}
int Employee::getEmpNum() const
{
return EmpNum;
}
int Employee::getHireDate() const
{
return HireDate;
}
Employee::Employee()
{
cout << "I will ask you some questions about an employee.\n\n";
}
class ProductionWorker : public Employee
{
private:
int Shift;
double HourlyPayRate;
public:
void setShift(int);
void setHourlyPayRate(double);
int getShift() const;
double getHourlyPayRate() const;
ProductionWorker();
};
void ProductionWorker::setShift(int a)
{
Shift = a;
}
void ProductionWorker::setHourlyPayRate(double b)
{
HourlyPayRate = b;
}
int ProductionWorker::getShift() const
{
return Shift;
}
double ProductionWorker::getHourlyPayRate() const
{
return HourlyPayRate;
}
ProductionWorker::ProductionWorker()
{
cout << "After answering the questions,\n";
cout << "I will display the employee's information.\n\n\n";
}
int main()
{
ProductionWorker info;
char name[100];
int num;
int date;
int shift;
double rate;
cout << "What is the employee's name? ";
cin.getline(name, 100);
cout << "What is the employee's number? ";
cin >> num;
cout << "What is the employee's hire date?\n";
cout << "(Month, day, and year without any slashes,\n";
cout << "dashes, commas, or other punctuation.)\n";
cout << "For example, January 14, 1983 would look like 01141983. ";
cin >> date;
cout << "Does the employee work shift 1 or shift 2? ";
cin >> shift;
cout << "How much does the employee make per hour? ";
cin >> rate;
info.setEmpName(name[100]);
info.setEmpNum(num);
info.setHireDate(date);
info.setShift(shift);
info.setHourlyPayRate(rate);
cout << "\n\nHere is the employee's data:\n\n";
cout << "Employee's Name: " << info.getEmpName() << endl;
cout << "Employee's Number: " << info.getEmpNum() << endl;
cout << "Employee's Hire Date: " << info.getHireDate() << endl;
cout << "Employee's Shift: " << info.getShift() << endl;
cout << setprecision(2) << fixed;
cout << "Employee's Hourly Pay Rate: $" << info.getHourlyPayRate() << endl << endl;
return 0;
}
This is wrong: you're accessing an out-of-range character instead of passing the array to the function
char name[100];
//.. initialize name..
info.setEmpName(name[100]); // Accesses the 100th character (out-of-range [0-99])
void Employee::setEmpName(char x)
{
EmpName = x;
}
I would go for using std::string by changing EmpName (also wrong, it's not a single character) to a std::string
class Employee
{
private:
string EmpName;
int EmpNum;
int HireDate;
public:
void setEmpName(std::string& name);
void setEmpNum(int);
void setHireDate(int);
string getEmpName() const;
int getEmpNum() const;
int getHireDate() const;
Employee();
};
Also don't forget to change char name[100] to a std::string in the main function.
Live Example
You can of course accomplish this also with char arrays, in that case if you intend to use a fixed-size array you could either pass it by reference or just copy the content of a pointer to the array into a memory array for Employee.
There are multiple problems with your code.
First, the data type of Employee::EmpName should not be char. It should be a char array or even better would be a std::string.
Second the parameter of the setEmpName function should be either a const char* or a const std::string&.
Third, the name variable should perhaps be a std::string instead of a char array. Of course if you make that change the parameter of the setEmpName function should be const std::string&.
Fourth, when calling the setEmpName function you should just call it as follows: info.setEmpName(name).
Next, you should use std::getline(cin, name) instead of cin.getline(name, 100).
I'm first correcting your mistakes and then giving you a better alternative solution.
The member of your class and the setter function's parameter are only a single char. Change them to arrays:
char EmpName[100];
and
void setEmpName(char[]);
and in the implementation, you need to copy the content of the given array to your member:
void Employee::setEmpName(char[] x) {
memcpy(EmpName, x, 100);
}
However, this is the C way to do this.
The C++ way to do this is to use std::string. For this, change the types of the member, the parameters in the setter and in the getter as well as the type in main to std::string. To read a std::string, use the free-standing overload of getline which only takes the stream and the string (but no count):
getline(cin, name);

2 Link Errors, 1 from a virtual functions, 1 from a derived class

I'm getting a LNK 2019 and 2001 error every time I compile. LNK2019 states:
public: __thiscall ColMbr::ColMbr(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0ColMbr##QAE#IV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z) referenced in function "public: __thiscall Alumni::Alumni(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Alumni##QAE#IV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##HHH0#Z
So there is some kind of error linking ColMbr class with Alumni. LNK2011 says:
"public: virtual void __thiscall Alumni::addClass(unsigned int,unsigned int)" (?addClass#Alumni##UAEXII#Z)
So there's an issue with my virtual function call. I understand that the LNK errors means there was a variable that needed to be declared that I missed but I don't see it. Firstly, the Alumni::addClass function is just there to make sure Alumni does not become an abstract class like ColMbr, which it's derived from. Secondly, all of the arguments in Alumni are defined and declared either in Alumni or in ColMbr.
If it was anything I'd say LNK2019 is probably a problem with my const unsigned int idNbr. I don't know what's wrong with LNK2001. Maybe I need to give the function a garbage purpose or something.
This is my header file followed by the cpp.
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
#ifndef _ColMbr
#define _ColMbr
class ColMbr
{
protected:
const unsigned int idNbr;
std::string name;
public:
ColMbr();
ColMbr(const unsigned int idNbr, std::string stdnt_name);
std::string setName(std::string stdnt_name);
virtual void display(void);
virtual void addClass(unsigned int credits, unsigned int gradePoint) = 0;
};
#endif // !1
std::string ColMbr::setName(std::string stdnt_name)
{
name = stdnt_name;
return name;
}
class Student : public ColMbr
{
private:
unsigned int credHrs, qualPts;
std::string degSought;
double GPA;
public:
Student(unsigned int idNbr, std::string name) : ColMbr (idNbr, name)
{
credHrs = 0;
qualPts = 0;
degSought = "Unspecified";
}
Student(const unsigned int idNbr, std::string stdnt_name, unsigned int credHrs1, unsigned int qualPts1, std::string newDegree) : ColMbr(idNbr,stdnt_name)
{
credHrs = credHrs1;
qualPts = qualPts1;
degSought = newDegree;
}
void setDegree(std:: string newDegree);
double getGPA(unsigned int credHrs, unsigned int qualPts);
void addClass(unsigned int newClass, unsigned int newQualPts)
{
credHrs = credHrs + newClass;
qualPts = qualPts + newQualPts;
}
void display(void)
{
std::cout << "This student is active." << std::endl <<"ID #: "
<< idNbr << std::endl << "Name: " << name << std::endl
<< "GPA: " << GPA << std::endl << "Major: " << degSought
<< std::endl;
}
};
void Student::setDegree(std:: string newDegree)
{
degSought = newDegree;
}
double Student::getGPA(unsigned int credHrs, unsigned int qualPts)
{
double credHrs1, qualPts1;
std::istringstream input(credHrs);
input >> credHrs1;
std::istringstream input1(qualPts);
input >> qualPts1;
GPA = qualPts1 / credHrs1;
return GPA;
}
#ifndef _Alumni
#define _Alumni
class Alumni : public ColMbr
{
private:
std::string degree;
int month, day, year;
public:
Alumni(const unsigned int idNbr, std::string stdnt_name, int gradMonth, int gradDay, int gradYear, std::string newDegree) : ColMbr(idNbr, stdnt_name)
{
degree = newDegree;
month = gradMonth;
day = gradDay;
year = gradYear;
}
void addClass(unsigned int credits, unsigned int gradePoint);
void display (void)
{
std::cout << "This student is an Alumni." << std::endl <<"ID #: "
<< idNbr << std::endl << "Name: " << name << std::endl
<< "Graduation Date: " << month << "/" << day << "/" << year
<< std::endl << "Major: " << degree << std::endl;
}
};
#endif
/**********************************************
#include <iostream>
#include <cstdlib>
#include "ColMbrs.h"
int main()
{
ColMbr *cMbr[4]; // array of base-class pointers
int i; // index to array
// Create some college members
cMbr[0] = new Student( 12345, "Steven DiFranco", 15, 33, "AA" );
cMbr[1] = new Alumni( 98765, "Don Green", 12, 15, 1978, "AAS" );
cMbr[2] = new Alumni( 24680, "Henry Thoreau", 5, 22, 1846, "AA" );
cMbr[3] = new Student( 13579, "Millenia Best" );
// display the array
cout << "All college members:\n";
for( i = 0; i < 4; ++i )
{
cMbr[i]->display(); // no need to check type field or cast
cout << endl;
}
// test addClass for student
cMbr[3]->addClass( 3, 12 );
cMbr[3]->display();
cout << endl;
system("PAUSE");
return 0;
}
So, this is how I got my code to compile and run correctly.
I declared both the constructor and the function that were giving me problems outside the class. After that I had to put an assignment for GPA from the GPA function into the Student::display(void) function. Finally, I couldn't figure out how to initialize the const unsigned in idNbr in the ColMbr class from the ColMbr(const unsigned int idNbr, std::string stdnt_name) constructor so I took the const label off the variable.
Here's the code for the header file. The .cpp remains the same.
Edited to reflect how I solved const unsigned int idNbr problem.
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
#ifndef _ColMbr
#define _ColMbr
class ColMbr
{
protected:
unsigned const int idNbr;
std::string name;
public:
//A default and initial constructor are called.
ColMbr();
ColMbr(const unsigned int id, std::string stdnt_name) : idNbr(id)
{
name = setName(stdnt_name);
}
virtual ~ColMbr();
std::string setName(std::string stdnt_name);
//ColMbr is made into an abstract class. It can not be called except with
//a pointer.
virtual void display(void);
virtual void addClass(unsigned int credits, unsigned int gradePoint) = 0;
};
#endif // !1
ColMbr::~ColMbr(){}
void ColMbr::display(void)
{
}
std::string ColMbr::setName(std::string stdnt_name)
{
name = stdnt_name;
return name;
}
class Student : public ColMbr
{
private:
unsigned int credHrs, qualPts;
std::string degSought;
double GPA;
public:
//A constructor with no additional Student attributes is created.
Student(unsigned int idNbr, std::string name) : ColMbr (idNbr, name)
{
credHrs = 0;
qualPts = 0;
degSought = "Unspecified";
}
//A constructor that adds Student attributes is created.
Student(const unsigned int idNbr, std::string stdnt_name, unsigned int credHrs1, unsigned int qualPts1, std::string newDegree) : ColMbr(idNbr,stdnt_name)
{
credHrs = credHrs1;
qualPts = qualPts1;
degSought = newDegree;
}
~Student();
//Functions for initializing the variables that will be output.
void setDegree(std:: string newDegree);
static double getGPA(unsigned int credHrs, unsigned int qualPts);
//The virtual functions are overwritten. Addclass allows for a change in GPA.
void addClass(unsigned int newClass, unsigned int newQualPts)
{
credHrs = credHrs + newClass;
qualPts = qualPts + newQualPts;
}
void display(void)
{
GPA = getGPA(credHrs, qualPts);
std::cout << "This student is active." << std::endl <<"ID #: "
<< idNbr << std::endl << "Name: " << name << std::endl
<< "GPA: " << GPA << std::endl << "Major: " << degSought
<< std::endl;
}
};
Student::~Student(){}
void Student::setDegree(std:: string newDegree)
{
degSought = newDegree;
}
//getGPA is declared and new students receive a 0
double Student::getGPA(unsigned int credHrs, unsigned int qualPts)
{
double GPA;
double credHrs1, qualPts1;
if (credHrs == 0)
{
GPA = 0;
}
else
{
credHrs1 = static_cast<double>(credHrs);
qualPts1 = static_cast<double>(qualPts);
GPA = qualPts1 / credHrs1;
}
return GPA;
}
#ifndef _Alumni
#define _Alumni
class Alumni : public ColMbr
{
private:
std::string degree;
int month, day, year;
public:
//An alumni constructor is defined.
Alumni(const unsigned int idNbr, std::string stdnt_name, int gradMonth, int gradDay, int gradYear, std::string newDegree) : ColMbr(idNbr, stdnt_name)
{
degree = newDegree;
month = gradMonth;
day = gradDay;
year = gradYear;
}
~Alumni();
//The virtual classes are overwritted.
//Even though addClass has no function here it is overwritten to ensure Alumni is not an abstract class.
void addClass(unsigned int credits, unsigned int gradePoint);
void display (void)
{
std::cout << "This student is an Alumni." << std::endl <<"ID #: "
<< idNbr << std::endl << "Name: " << name << std::endl
<< "Graduation Date: " << month << "/" << day << "/" << year
<< std::endl << "Major: " << degree << std::endl;
}
};
#endif
Alumni::~Alumni(){}
void Alumni::addClass(unsigned int credits, unsigned int gradePoint)
{}