#GESP1884. [GESP]L5-202309-Q1884-S

[GESP]L5-202309-Q1884-S

有关下面 C++ 代码正确的是( )。

#include <iostream>
using namespace std;

bool isOdd(int N) {
    return N % 2 == 1;
}

int Square(int N) {
    return N * N;
}

bool checkNum(bool (*Fx)(int), int x) {
    return Fx(x);
}

int main() {
    cout << checkNum(isOdd, 10) << endl;  // 输出行A
    cout << checkNum(Square, 10) << endl; // 输出行B
    return 0;
}

{{ select(1) }}

  • checkNum() 函数定义错误。
  • 输出行 A 的语句将导致编译错误。
  • 输出行 B 的语句将导致编译错误。
  • 该代码没有编译错误。