回复:C++ 高手请进... very interestin

1. What will be in variable ‘q’ after line 201 is executed? Under what conditions might this not be so?
q = b[0], if b != NULL.

2. Is there an alternative, but equivalent, way to write line 2000? If so, what is it?
no, line 2000 returns a character pointer. unless you change the type and passing parameter of the function.

3. Is getbuf() a reasonable function?
No, it returns a pointer of a local memory, which will destroy itself once the function finishes execution.

4. Will getbuf() execute at all?
Maybe, i haven't seen the function prototyping at all, it might not even compile w/o functionl prototype.

5. Please comment on line 2051.
bad, use return &buff[0] instead, in UNIX, simply use return (buff), _WIN32 application, same method will generate a warning, use return &buff[0].

6. Is getbuf() good practice, and why?
Nope, declare either static char buff[8], (memory remains) or use it as a passing parameter getbuff(char * inBuff)


7. What line not given should be provided for compilation?
I need function prototype of getbuff in order to compile.

8. How, exactly, could one get a second ‘char *’ to use back from this function? Be specific in terms of the exact syntax needed. (That is, provide code.) Another way to state this question is how can this function be modified to return a ‘char *’ (that is, it maintains the same return type) from the function, and an additional ‘char *’ value in one function call. Please make sure that your answer will work even if the size of the char * desired is not known in the outside calling function. Avoid (do not use) C++ syntax. Include statements in called and calling functions. Use good programming practice.

char * buff(char * secondBuff, int sencodBuffLength)
{
static char buff[8];
// you modify both the buff and secondBuff here...
return &buff[0];
}


9. For those candidates who know SQL: There is a table with gene_ids (‘gid’) and clone_ids (‘cid’). Each gene only resides on a single clone and each clone may contain multiple genes. How do you find how many genes are on each and every clone? Please provide the SQL.

f*u*ck SQL

10. What's the difference between system calls and library functions?
system (OS) defined and user (you or other s/w vendors) defined.

请您先登陆,再发跟帖!