I wrote this code for my class, but I cannot get the second class to call the default constructor. Please help and any assistance would greatly be appreciated. The first class works, but I cannot get the second one to call the first constructor. The header file constains all prototypes and private data members (I have not included it).
#include <iostream>
#include "CheapWatch.h"
using namespace std;
int main()
{
long num = 18637;
CheapWatch milTime( num );
CheapWatch newTime();
}
CheapWatch::CheapWatch()
: hours( 0 ), minutes( 0 ), seconds( 0 )
{
long temp = 0;
cout << " Please input the total number of seconds : ";
cin >> temp;
cout << endl;
CheapWatch temp1( temp );
}
CheapWatch newTime();
The compiler will see this as a function declaration. A function named newTime that returns a CheapWatch. Remove the parenthesis and the compiler will understand. CheapWatch newTime;