• 2021-04-14
    已知程序中已经定义了函数test,其原型是int test (int,int,int);,则下列重载形式中正确的是( )。 A.char test(int, int, int); B.double test (int,int,double); C.int test(int ,int, int=0); D.float test(int,int,float=3.5F);
  • 正确答案:B

    内容

    • 0

      以下是"public static void test(int x, int y)"的方法重载( ) A: public static void Test(int x) B: public static int test(int x, int y) C: public static void test(int y, int x) D: public static void test(int x, int y)

    • 1

      有一个类Test,下面为其构造方法的声明,正确的是( )。 A: void Test(int i){} B: test(int i){} C: void test(int i){} D: Test(int i){}

    • 2

      阅读以下程序,写出运行结果。 #include using namespace std; class Test { private: int num; public: Test(); Test(int n); }; Test::Test() { cout << "Init defa" << endl; num = 0; } Test::Test(int n) { cout << "Init" << " " << n << endl; num = n; } int main() { Test x[2]; Test y(15); return 0; }

    • 3

      下列程序的输出结果是 _____ 。 #include using namespace std; class Test { public: Test() { cnt++; } ~Test() {cnt--; } static int Count() { returncnt;} private: static int cnt; }; int Test::cnt = 0; int main() { cout << Test::Count()<<' '; Test tl, t2; Test* pT3 = new Test; Test* pT4 = new Test; cout << Test::Count()<<' '; delete pT4; delete pT3; cout << Test::Count()<< endl; return 0; }

    • 4

      Test类中声明一个整型静态成员函数fun()的正确语句是_____。 A: int static fun(); B: int fun() static; C: static int fun(); D: int Test::fun() static;