私は引数としてfoo()
2 を受け取る関数を書いていました。null で終了する文字列が渡されます。デフォルトでは、文字列の (最後の文字) を指します。const char*
pBegin
pEnd
foo()
pEnd
\0
void foo (const char *pBegin,
const char *pEnd = strchr(pBegin, 0)) // <--- Error
{
...
}
ただし、上記の行で次のようなエラーが発生します。
error: local variable ‘pBegin’ may not appear in this context
なぜコンパイラはそのような操作を許可しないのですか? 潜在的な問題は何ですか?