arrays in classes

Can anyone tell me how to fill this array from an infile?? I'm so confused. We just started on classes I'm just not sure how to fill this array from an infile I know my code is wrong but I'm not understanding how to do what I need to do with things being private.

#include <iostream>
#include <fstream>

using namespace std;
const int ARRAY_SIZE=10;
class clockType
{
public:
void setTime(int,int,int);
void getTime(int& ,int& ,int& )const;
void print()const;
clockType(int=0,int=0,int=0);

private:
int hr;
int min;
int sec;

};

void print(clockType[]);
void fill(clockType[]);
int main ()
{
clockType timeIn[5];
print(timeIn);
fill(timeIn);
print(timeIn);
}
void print(clockType in[])
{
for(int i=0;i<5;i++)
{
cout<<"Employee"<<i+1<<" clock in time = ";
in[i].print();
cout<<endl;
}
}
void fill (clockType in[])
{
ifstream inFile;
inFile.open("mymenus.txt");

int h,m,s;
for(int i =0;i<5;i++)
{
cout<<"Enter clock in time"<< i+1<<" ";
int counter=0;
for (int i=0; i<ARRAY_SIZE;i++)
{
getline(inFile,in[i].h);
getline(inFile,in[i].m);
getline(inFile,in[i].s);
in[i].setTime(h,m,s);

counter++;
}
cout<<endl;
}
}
void clockType::setTime(int hours,int minutes,int seconds)
{
if(0<=hours&&hours<24)
hr=hours;
else hr=0;
if(0<=minutes&&minutes<60)
min=minutes;
else min=0;
if(0<=seconds&&seconds<60)
sec=seconds;
else sec=0;

}
void clockType::getTime(int& hours,int& minutes, int& seconds)const
{
hours=hr;
minutes=min;
seconds=sec;
}

void clockType::print()const
{
if(hr<10)
cout<<"0";
cout<<hr<<":";

if (min<10)
cout<<"0";
cout<<min<<":";

if (sec<10)
cout<<"0";
cout<<sec<<":";
}
clockType::clockType(int,int,int) //default constructor
{
hr = 0;
min = 0;
sec = 0;
}
Topic archived. No new replies allowed.