June 29, 2006 function can't accept class type as paramater?!! | ||||
---|---|---|---|---|
| ||||
i really can't figure out why i can't this working, and it always errors out on the parameter list of brceme #include "stdlib.h" #include "time.h" #include "iostream.h" #include "string.h" #define std; #define ITERS 5; #define PLYRS 2; #define CMBS 3; // rps.. or more?! void brceme(string lala) { cout << lala << endl; } int main () { int i, i2; srand ( time( NULL ) ); // init for ( i2 = 0; i2 <= ITERS; i2++ ) { cout << "game " << i2 << endl; for ( i = 1; i <= PLYRS; i++ ) { cout << i << " alalalal" << endl; } } } /* this will out put: C:\cpp>rps.cpp void brceme(STRING lala) { cout << lala << endl; } ^ C:\cpp\rps.cpp(11) : Error: ')' expected to close function parameter list with srand ( time( NULL ) ); // init ^ C:\cpp\rps.cpp(19) : Error: 'srand' is not in function parameter list for ( i2 = 0; i2 <= ITERS; i2++ ) { ^ C:\cpp\rps.cpp(20) : Error: '=', ';' or ',' expected for ( i = 1; i <= PLYRS; i++ ) { ^ C:\cpp\rps.cpp(22) : Error: '=', ';' or ',' expected } ^ C:\cpp\rps.cpp(24) : Error: '=', ';' or ',' expected Fatal error: too many errors --- errorlevel 1 C:\cpp> */ i must be missing something simple!?!? i've tried tons of variations on "string", lower-case/as a * pointer/ positioning of the pointer .. etc... and i see that obviously one can supply a class type for a parameter... so i'm baffled. rjm |
June 30, 2006 Re: function can't accept class type as paramater?!! | ||||
---|---|---|---|---|
| ||||
Posted in reply to robertjaym | robertjaym@gmail.com wrote: > i really can't figure out why i can't this working, and it always errors out on > the parameter list of brceme > > #include "stdlib.h" > #include "time.h" > #include "iostream.h" > #include "string.h" Make that: #include <stdlib.h> #include <time.h> #include <iostream> #include <string> > #define std; And: using namespace std; > > #define ITERS 5; > #define PLYRS 2; > #define CMBS 3; // rps.. or more?! And no ; after defines, i.e: #define ITERS 5 #define PLYRS 2 #define CMBS 3 // rps.. or more?! And every one will be happier. -- Absolutely not the best homepage on the net: http://home20.inet.tele.dk/midgaard But it's mine - Bertel |
Copyright © 1999-2021 by the D Language Foundation