I am getting compilation error in this code, i am unable to find, what's wrong. kindly help.
Compilation error is
7.cpp:36: error: expected ‘;’ before ‘t1’
7.cpp:38: error: ‘t1’ was not declared in this scope
7.cpp:39: error: ‘t2’ was not declared in this scope
7.cpp:44: error: ‘t3’ was not declared in this scope
#include <iostream>
usingnamespace std;
class time {
int h;
int m;
public:
void getdata(int a, int b)
{
h = a;
m = b;
}
void putdata(void)
{
cout << h << " " << m << endl;
}
void sum(time,time);
};
void time :: sum(time t1, time t2)
{
int p = t1.h + t2.h;
int q = t1.m + t2.m;
p += q/60;
q %= 60;
h = p;
m = q;
}
int main()
{
time t1, t2, t3;
t1.getdata(2,45);
t2.getdata(3,30);
t1.putdata();
t2.putdata();
t3.sum(t1,t2);
t3.putdata();
return 0;
}