c++ - How does this function definition work? -
i generated hash function gperf couple of days ago. saw hash function alien me. (i don't remember exact syntax) :
unsigned int hash(str, size) register char* str; register unsigned int size; { //definition } now, when tried compile c++ compiler (g++) threw errors @ me not having str , size declared. compiled on c compiler (gcc). so, questions:
- i thought c++ superset of c. if so, should compile c++ compiler right?
- how c compiler understand definition?
str,sizeundeclared when first appear. - what purpose of declaring
str,sizeafter function signature before function body rather following normal approach of doing in either of 2 places? - how function compile on g++ can use in c++ code? or should try generating c++ code gperf? possible?
1. c++ not superset, although not standard c either.
2/3. k&r function declaration. see what major differences between ansi c , k&r c? .
4. gperf in fact have option, -l, specify language. can use -l c++ use c++.
Comments
Post a Comment