Hello, I am new to working with structs and classes and seem to have run into a few issues. For the most part I think I have structs down but I am still have some trouble understand classes.
I am currently working on a program that will create an employee database for five employees.
I don't understand why I am getting compiler errors. It is saying that my variables in the bool function are undefined but they are private variables and I was under the impression that function accessing variables from within the same class could use those same variables. This only seems to be an issue with the bool function. Also if anyone could give me some direction as to how to take the program from here it would be greatly appreciated. Thanks!
So far I have this set up.
Code:
#include <iostream>
using namespace std;
const int MAX = 5;
struct nameType
{
string first;
char mid;
string last;
};
struct dateType
{
int month;
int day;
int year;
};
struct RecType
{
nameType employee;
nameType supervisor;
dateType dob;
dateType starting;
float rate;
int id_Num;
int hours;
float gross;
float all_Gross;
};
class ListType
{
public:
ListType ( );
void Insert(RecType);
bool GetNext(RecType&);
void Reset( );
private:
RecType DB[MAX];
int current;
int noemp;
};
ListType::ListType( )
{
current = 0;
noemp = 0;
}
void ListType::Insert(RecType rec)
{
DB[current] = rec;
current++;
noemp++;
}
bool GetNext::(RecType& rec)
{
if (current == noemp || noemp == 0)
return false;
else
{
rec = DB[current];
current++;
}
}
void Reset( )
{
current = 0;
}
int main()
{
}