| Re: Problem compiling with g++ |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.c++.moderated · Group Profile
Author: nickf3nickf3 Date: May 22, 2008 14:00
On May 22, 7:57 am, gauravd...@ gmail.com wrote:
> This is my code for a simple program but during compiling with g++ it
> gives some errors listed below. i don't know why and i am not able to
> get it-->
>
> My code:
>
> #include
>
> using namespace std;
>
> class time
>
> {
>
> int hours, minutes;
>
> public:
>
> void getTime(int h, int m)
>
> {
>
> hours = h;
>
> minutes = m;
>
> }
>
> void putTime(void)
>
> {
>
> cout<
>
> cout<
>
> }
>
> void sum(time,time); //declaration with objects as arguments
>
> };
>
> void time :: sum(time t1, time t2)
>
> {
>
> minutes = t1.minutes + t2.minutes;
>
> hours = minutes/60;
>
> minutes = minutes%%60;
>
> hours += t1.hours + t2.hours;
>
> }
>
> int main()
>
> {
>
> time T1 ,T2, T3;
>
> T1.getTime(2,45);
>
> T2.getTime(3,30);
>
> T3.sum(T1,T2);
>
> cout<< "T1 = ";
>
> T1.putTime(); //display T1
>
> cout<< "T2 = ";
>
> T2.putTime(); //display T2
>
> cout<< "T3 = ";
>
> T3.putTime(); //display T3
>
> return 0;
>
> }
>
> Error generated:
>
> gauravdott@gauravdott-desktop:/media/Baki Sab bacha Kucha/Ebooks n
> docs/Gaurav's docs/My assingments/C++$ g++ -o objArg.out objArg.cpp
>
> objArg.cpp: In function 'int main()':
> objArg.cpp:34: error: expected `;' before 'T1'
> objArg.cpp:36: error: 'T1' was not declared in this scope
> objArg.cpp:37: error: 'T2' was not declared in this scope
> objArg.cpp:38: error: 'T3' was not declared in this scope
>
> Please any one can tell the problem......
>
You are colliding with the library function "time":
goo.cpp: In function `int main()':
goo.cpp:55: error: expected `;' before "T1"
goo.cpp:55: warning: statement is a reference, not call, to function
`time'
goo.cpp:55: warning: statement has no effect
goo.cpp:57: error: `T1' was not declared in this scope
...
Hint: add at least -Wall to your compiler invocation.
|