Re: [C++] Help Please! Can't find error, redefines variable
From: Jonathan Mcdougall (jonathanmcdougall_at_DELyahoo.ca)
Date: 10/08/03
- Next message: Jonathan Mcdougall: "Re: [OT, FAQ, link] Debug request"
- Previous message: Jonathan Mcdougall: "Re: return return new int[] { pounds, shilings, pence}; to main"
- In reply to: Andreas Heckmeier: "[C++] Help Please! Can't find error, redefines variable"
- Next in thread: Andreas Heckmeier: "Re: [C++] Help Please! Can't find error, redefines variable"
- Reply: Andreas Heckmeier: "Re: [C++] Help Please! Can't find error, redefines variable"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 7 Oct 2003 23:13:49 -0400
> void main(void)
main returns an int and using (void) to signify an empty parameter list
is (generally) considered bad style in C++.
int main()
> {
> stringstream msg1;
> stringstream msg2;
>
> //variable which contains the actual simulation time
>
> do
> {
> double t = 0;]
't' gets destroyed and recreated at each loop. It should have a value of
0 at each turn. And what's the bracket doing here?
> if(t>=100) //if time is greater or equal than 100 seconds, stop
loop
> break;
Never gonna happen.
<snip>
> Now, everything seems to work fine. And the simulation actualy works...
It should not, well it works only for t==0 since it gets recreated every
time.
If it works for real, there is a serious bug in your compiler.
Actually I think that was dummy code, if only for the typos. Post some
real code and make sure to format it for 72 characters wide since it is
pretty much the standard over usenet.
Jonathan
- Next message: Jonathan Mcdougall: "Re: [OT, FAQ, link] Debug request"
- Previous message: Jonathan Mcdougall: "Re: return return new int[] { pounds, shilings, pence}; to main"
- In reply to: Andreas Heckmeier: "[C++] Help Please! Can't find error, redefines variable"
- Next in thread: Andreas Heckmeier: "Re: [C++] Help Please! Can't find error, redefines variable"
- Reply: Andreas Heckmeier: "Re: [C++] Help Please! Can't find error, redefines variable"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|