Hello everyone.
I need help using an instance of a class in another. Below are two header files. NumDays.h and TimeOff.h
I need to have instances of the NumDays class in the TimeOff class as members. When i try to create the instance called maxSickDays, i do not get access to the NumDays member functions. What is wrong with my code? Thanks in advance.
NumDays.h
#ifndef NUMDAYS
#define NUMDAYS
#include <iostream>
class NumDays
{
private:
int hours;
float days;
float calcDays();
public:
NumDays()
{ hours = 0; days = 0.0; }
void setHours(int hrs)
{ hours = hrs; }
int getHours()
{ return hours; }
float getDays();
NumDays operator + ( const NumDays& );
NumDays operator - ( const NumDays& );
NumDays operator --();
NumDays operator ++();
NumDays operator ++ ( int );
NumDays operator -- ( int );
};
#endif
and now TimeOff.H
#ifndef TIMEOFF
#define TIMEOFF
#include <iostream>
#include "NumDays.h"
#include <string>
using namespace std;
class TimeOff
{
private:
string name;
int idNum;
NumDays maxSickDays;
public:
TimeOff();
void setName ( string n )
{ name = n; }
void setIdNum ( int id )
{ idNum = id; }
string getName()
{ return name; }
int getIdNum()
{ return idNum; }
};
#endif
Thank you!