Hello...Im having a problem figuring out how to convert a long datatype to an object...as well converting a user-defined type to a long datatype.....here is what i wrote so far...any help would be appreciated. Thanks!
Code:
class Time
{
private:
int hrs; //1 to 23
int mins; //0 to 59
int secs; //0 to 59
public: //no-arg constructor
Time() : hrs(0), mins(0), secs(0)
{ }
.....
Time(long allSeconds)
{
allSeconds = Time(secs);
}
operator long()
{
return secs;
}
};
void main(void_
{
......
// Statement to test the conversion functions
long allSeconds = 77777;
Time t6(allSeconds);
cout << '\n' << allSeconds << " converts to ";
t6.display();
allSeconds = long(t5);
cout << '\n'; t5.display();
cout <<" converts to " << allSeconds;
}