I tried searching for answers for this error and tried the suggested fixes but nothing helped so I am asking for help. I keep receiving id returned 1 exit status error. I am using Dev-C++ as the IDE.
This is my header file:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class Record
{
private:
string name;
int id;
double rate;
double hours;
public:
Record();
Record (string n, int empid, double hourlyRate, double hoursWorked);
// constructor
void read_data_from_file();
double calculate_wage();
void print_data();
/* SETTERS AND GETTERS */
void set_name (string n);
string get_name();
void set_id (int empid);
int get_id();
void set_rate (double hourlyRate);
double get_rate();
void set_hoursWorked(double hoursWorked);
double get_hoursWorked();
/* END OF SETTERS AND GETTERS */
};
and this is my Record.cpp
#include "Record.h"
Record::Record(string n, int empid, double hourlyRate, double hoursWorked)
{
name = n;
empid = id;
hourlyRate = rate;
hoursWorked = hours;
}
//
void Record::set_name(string n)
{
name = n;
}
string Record::get_name()
{
return name;
}
//
void Record::set_id(int empid)
{
id = empid;
}
int Record::get_id()
{
return id;
}
//
void Record::set_rate(double hourlyRate)
{
rate = hourlyRate;
}
double Record::get_rate()
{
return rate;
}
//
void Record::set_hoursWorked(double hoursWorked)
{
hours = hoursWorked;
}
double Record::get_hoursWorked()
{
return hours;
}
//
And ofcourse, I have an int main() function.
#include "Record.h"
int main()
{
Record employee;
ifstream myFile;
return 0;
}
Just a side note: this is my first project related to using class, there might be an easier way to do this, but this is what I could think of.
You forgot to implement the default constructor (which you call in main). Add this to your .cpp:
Record::Record() : name(), id(0), rate(0), hours(0) { }