View Single Post
 
Reply
Posted 2003-10-14, 05:00 PM in reply to Chruser's post "Unmanageable C++ code"
This is the first one, as far as I can figure out (only 1 year of C++, like 3 years ago).


Code:


#include <iostream.h>
#include <stdlib.h>

struct WierdVarType {int A; int B;};

void main()
{


   WierdVarType test={12,1337}; 
   test.A += 5; 
   cout << test.A << endl;


   for(;;)  /*Yay for infinite loops*/
      { 
         cout << ++test.B << endl;
      }

}


...

So would the output be:

17
1338
1339
1340
1341
1342
1343
1344
(and so on)

I'm not quite sure. I think the ++test.B would increment before it prints out on screen.

Unless I screwed it up and it doesn't compile..

Hmm.. seems I need more C++ classes!
Old
Profile PM WWW Search
BlueCube enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHzBlueCube enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHz
 
 
BlueCube