c++ - Functions used by one function in header file -


context

i'm writing function uses other functions needed in main function. purpose of main function make sort of kit call required functions.

exemple

int a(int x) // make x = 10 in recursive way , purpose limited               // used function b {     if (x == 10) return x;     else if(x<10) return a(x+1);     else return a(x-1); }  int b(int x, int allow_b) // exemple, function b call function if required. {     if (allow_b == 1) return a(x);     else return x; } 

question

since function 'a' exist used 'b', should there particular done in header file or should commented on function 'a' used 'b' ?

is there wrong kind of approach?

edit

i mean should declared in header, i'm not talking writing function 'a' , 'b' in header file.

if function a used b, see no need declared in header file.

put both functions in same translation unit, , declare , define function a static linkage, additional constraint, prevent being accessible other translation units.

it's possible various logistical reasons 2 functions must in different translation units, require a declared in header file. in case, thing can done comment , document this. might consider setting separate namespace a alone, emphasize this.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -