I'm stuck on an assignment question i need to do that asks me to change a struct into a class type.
I'm given the struct as,
struct Employee
{
string firstName;
string secondName;
float salary;
}
From there the main question is:
Turn the employee record into a class type rather than a structure type. The employee record class should have private member variables for all data. Include public member functions for each of the following:
Create a default constructor that sets the first name and last name to blank strings and salary to 0.
Create an overloaded constructor that sets the member variables to specified values.
Create member functions to set each of the member variables to a given value as an argument(i.e mutators)
Create member functions to retrieve data from each member variable(i.e accessors).
I then need to add this class to a simple test program to output the data.
My code so far:
#include <iostream>
#include <string>
using namespace std;
class EmployeeRecord
{
public:
EmployeeRecord(string firstName, string secondName, float salary);
EmployeeRecord();
void set(string firstName, string secondName, float salary);
void update();
string get_firstName();
string get_secondName();
float get_salary();
void output(ostream& outs);
private:
string firstName;
string secondName;
float salary;
};
int main()
{
EmployeeRecord employee1, employee2;
EmployeeRecord();
employee1.set("Joe", "Soap", 1456.00);
employee1.output(cout);
return 0;
}
EmployeeRecord::EmployeeRecord()
{
firstName = "";
secondName = "";
salary = 0.00;
}
My problem is that when I try to run the program i get undefined reference errors on lines 28 and 29 and I don't know what this means exactly. Any help to put me in the right direction would be appreciated as this is my first attempt at using classes in my code while trying to follow my textbooks example.
Sorry if this is a duplicate post or just a bad question.