次のコードは、VC++ および clang でコンパイルできません。
int f()
{
return 0;
}
int main()
{
// error : called object type 'int' is not a function or function pointer
int f = f();
}
場合によっては必要です。たとえば、 という名前の文字列の文字数を計算する関数がありcount
ますが、別の関数パラメーターも明示的に として名前が付けられていcount
ます。
size_t count(char* sz)
{
return strlen(sz);
}
bool check_count(char* sz, size_t count)
{
return count == count(sz); // ???
}
この問題を解決するにはどうすればよいですか?