niusouti.com

已知程序中已经定义了函数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);

题目

已知程序中已经定义了函数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);


相似考题
更多“已知程序中已经定义了函数test,其原型是int test(int, int, int);,则下列重载形式中正确的是A.ch ”相关问题
  • 第1题:

    已知“int*p;fun(p);”,其中,函数fun没有返回值,且其形参定义为引用调用方式,则下列给出的fun函数原型中正确的是()。

    A.voidfun(inta[]);

    B.voidfun(int*&a);

    C.voidfun(int&a[]);

    D.voidfun(int&*a);


    正确答案:B

  • 第2题:

    已知函数fun的原型为

    int fun(int,int,int);

    下列重载函数原型中错误的是

    A.char fun(int,int);

    B.double fun(int,int,double);

    C.int fun(int,char木);

    D.float fun(int,int,int);


    正确答案:D
    解析:重载函数至少要在参数个数或参数类型上有所不同。选项D)的重载函数只有返回值不同,其他(参数个数及类型)完全相同。因此,本题答案为D)。

  • 第3题:

    已知程序中已经定义了函数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

  • 第4题:

    将前缀运算符“--”重载为非成员函数,下列原型中能正确用于类中说明的是( )。

    A.DeCr&operator--(int);

    B.DeCr operator--(DeCr&,int);

    C.friend DeCr&operator--(DeCr&);

    D.friend DeCr operator--(DeCr&,int);


    正确答案:D
    非成员函数重载用友元函数的形式实现,“--”运算符重载分为前置和后置两种重载方式。用友元函数来实现“--”运算符的重载时,前置“--”运算符的重载的一般格式为:friend<type>operator--(ClassName&);后置++运算符的重载的一般格式为:friend<type>operator--(ClassName&,int)。所以答案为D。

  • 第5题:

    将前缀运算符“一一”重载为非成员函数,下列原型中,能正确用于类中说明的是( )。

    A.Deer&operator一一{int};

    B.Decroperator一一(Decr&,int);

    C.friendDeer&cperator一一(Deer&);

    D.friendDeeroperacor一一(Deer&,int);


    正确答案:C
    C。【解析】把“--”运算符重载为非成员(友元)函数格式:“friend<返回类型>operator--”是前缀的格式;friend<返回类型>operator--(int)是后缀的格式。当然也可以有参数如题中C选项所示。