Colora
Oct 28th, 2000, 06:50 PM
I'll post the whole code, otherwise you won't see where the function setup begins. I'm getting error C2601: 'calSeconds' : local function definitions are illegal.
Here 'tis:
//E2_26.cpp exercise 3.26
//create a stopwatch type program
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int calSeconds (int, int, int);
int main ()
{
int hour=0, min=0, sec=0, time1, time2, endtime;
cout<<"Enter a time, between 12:00 AM and 11:59:59 PM."<<endl;
cout<<"Use a space between hours, minutes, and seconds."<<endl;
cin>>hour>>min>>sec;
time1=calSeconds(hour,min,sec);
cout<<time1<<" seconds in total pass between 12:00 AM and the time you picked."<<endl;
cout<<"Enter a second time, to find the seconds occur between both times entered."<<endl;
cin>>hour>>min>>sec;
time2=calSeconds(hour,min,sec);
if (time1>time2)
endtime = time1 - time2;
else
endtime = time2 - time1;
cout<<endtime<<" seconds occur between the two times entered."<<endl;
int calSeconds (int x, int y, int z)
{
int t1 = 0;
t1 = ( (x*60*60) + (y* (60+z) ) );
return t1;
}
return 0;
}
Someone let me know what is so illegal about my local function definitions please? I'm thoroughly stuck on this.
Thanks, Colora
Here 'tis:
//E2_26.cpp exercise 3.26
//create a stopwatch type program
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int calSeconds (int, int, int);
int main ()
{
int hour=0, min=0, sec=0, time1, time2, endtime;
cout<<"Enter a time, between 12:00 AM and 11:59:59 PM."<<endl;
cout<<"Use a space between hours, minutes, and seconds."<<endl;
cin>>hour>>min>>sec;
time1=calSeconds(hour,min,sec);
cout<<time1<<" seconds in total pass between 12:00 AM and the time you picked."<<endl;
cout<<"Enter a second time, to find the seconds occur between both times entered."<<endl;
cin>>hour>>min>>sec;
time2=calSeconds(hour,min,sec);
if (time1>time2)
endtime = time1 - time2;
else
endtime = time2 - time1;
cout<<endtime<<" seconds occur between the two times entered."<<endl;
int calSeconds (int x, int y, int z)
{
int t1 = 0;
t1 = ( (x*60*60) + (y* (60+z) ) );
return t1;
}
return 0;
}
Someone let me know what is so illegal about my local function definitions please? I'm thoroughly stuck on this.
Thanks, Colora