C++ Using a class from a header within a class
- by Kotsuzui
I'm having a bit of trouble with classes used within classes, from header files.
I have an class time in time.h:
class Time
{
private:
int hour, second, minute;
public:
.
.
.
int getHour(int h);
etc.
setHour();
etc.
void print24hour(); // Prints time in 24 hour format
}
And then, main.cpp:
#include "time.h"
class Class
{
private:
string name;
double grade;
Time startTime;
Time endTime;
public:
Class();
~Class();
void setName();
void setGrade();
etc.
}
int main()
{
//Need to print time in 24 hour format, but I don't know how.
class[i].startTime.print24(getStartTime()); // ??? I'm rather lost
}
I get quite a few "hour, second, minute, etc." are private errors, I'm guessing I'm doing something simple in a rather wrong way. Please help.