回复:C++ 高手请进

来源: 2005-09-10 21:55:04 [旧帖] [给我悄悄话] 本文已被阅读:

You should answer questions like this:

First, whoever wrote the getbuf() function is an idiot and should be fired.

2) Are you asking if there is an alternative, but equivalent, way to be an idiot? Sorry, I can not answer this question.

4) Yes, it will execute, but depends on what it is written for:
a) If it is written for Windows, you will be just fine.
b) If it is written for a car, it may kill a few people every time.
c) If it is written for a airplane, it may kill a few hundred people every time.
d) If it is written for a nuclear weapon control system, ..., you may want to pray to God now because Jesus is coming very soon.

The biggest problem is about returning reference to local object (object lifetime problem). You understand this a little bit but can not tell it is compiler error or runtime error.
And you may not understand output parameter in C.
And the most important difference between system call and library function is about user-kernel boundary. And subroutine is not a proper word to discribe system call.
You certainly need more experience.