更多"下列程序中的重载函数disp( )发生错误,错误原因是 【13】 。 "的相关试题:
[填空题]下列程序中的重载函数disp( )发生错误,错误原因是______。
#include<iostream.h>
class Sample
private:
int m;
static int st;
public:
Sample(int a)m=a;st+=a;
static void disp( )cout<<m<<endl;
static void disp(Sample input)
cout<<input.m<<endl;;
int Sample::st=2;
void main( )
Sample First(2),Second(4);
Sample::disp( );
Sample::disp(Second);
[填空题]如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为 【8】 。
# include<iostream.h>
class test
{
private:
int num;
public:
test(int)
void show( );
};
test: :test(int n){ num=n;}
test:: show( ) { cout<<num<<end1; }
void main( )
{
test T(10);
T. show ( );
}
[填空题]如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为 【8】 。
# include<iostream.h>
class testprivate:
int num;
public:
test(int)
void show( );
;
test: :test(int n) num=n;
test:: show( ) cout<<num<<end1;
void main( ) test T(10);
T. show ( );
[填空题]如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为______。
#include<iostream.h>
class test
private:
int hum;
public:
test(int);
void show( );
;
test::test(int n)num=n;
test::show( )cout<<num<<endl;
void main( )
test T(10):
T.show( );
[单项选择]下列对重载函数的描述中,( )是错误的。
A. 重载函数中不允许使用默认参数
B. 重载函数中编译是根据参数表进行选择
C. 不要使用重载函数来描述毫无相干的函数
D. 构造函数重载将会给初始化带来多种方式
[单项选择]在下面的运算符重载函数的原型中,错误的是( )。
A. Volume operator-(double,double);
B. double Volume::operator-(double);
C. Volume Volume::operator-(Volume);
D. Volume operator-(Volume);
[单项选择]对定义重载函数的下列要求中,( )是错误的。
A. 要求参数的个数不同
B. 要求参数中至少有一个类型不同
C. 要求参数个数相同时,参数类型不同
D. 要求函数的返回值不同
[填空题]类class one 在声明func 成员函数时发生错误,出错原因是 【9】 。
Class one
private:
int a;
public:
void func(two& )
;
class two
private:
int b;
friend void one: :func(two & );
;
void one: : func(two& r)
a=r.b;
[填空题]下列程序的输出是3,请填充程序中的空缺,使该行形成一个运算符重载函数的定义。
#include
using namespace std;
class MyNumber{
int n;
public:
MyNumber(int k):n(k){}
_【9】_int()const{return n,}
};
int main(){
MyNumber numl(3);
Cout<
[填空题]重载函数的函数名称相同,但函数的实现和功能不同,系统是靠 【12】 来决定采用哪个函数。
[填空题]一个双目运算符作为类的成员函数重载时,重载函数的参数表中有()个参数。
[填空题]类clasg one在声明func成员函数时发生错误,出错原因是______。
class one
private:
int a;
public:
void func(two&);
;
class two
private:
int b;
friend vold one::func(two&);
;
void one::func(two&r)
a=r.b;
[填空题]函数重载要求重载的函数必须有和原函数一样的【 】。