更多"下列类的构造函数不能通过编译,正确的构造函数应该是______。 #"的相关试题:
[填空题]下列类的构造函数不能通过编译,正确的构造函数应该是______。
#include<iostream.h>
class Sample
public:
int n;
const int con;
Sample(int m) con=m+1;n=m;
void disp( ) cout<<"normal:n="<<n<<endl;
void disp( )const cout<<"static:n="<<n<<endl;
;
void main( )
const Sample a (12);
Sample b (13);
a.disp( );
b.isp( );
cout<<a.n<<","<<b.con<<endl;
[填空题]下列类的构造函数不能通过编译,正确的构造函数应该是 【15】 。
# inelude<iostream. h>
class Samplepublic:
int ns
const int con,
Sample(int m) con= m+1; n= m;
void disp( ) cout<<’"normal: n="<<n<<end1;
void disp( )const cout<<"static: n="<<n<< end1;
;
void main( ) const Sample a(12),
Sample b(13),
a. disp( ),
b. disp( )
cout<<a, n<< "<<b. con<<end1;
[填空题]下列类的构造函数不能通过编译,正确的构造函数应该是 【15】 。
# inelude<iostream. h>
class Sample
{
public:
int ns
const int con,
Sample(int m) { con= m+1; n= m;}
void disp( ) {cout<<’"normal: n="<<n<<end1; }
void disp( )const {cout<<"static: n="<<n<< end1; }
};
void main( )
{
const Sample a(12),
Sample b(13),
a. disp( ),
b. disp( )
cout<<a, n<< "<<b. con<<end1;
}
[填空题]下列类的构造函数不能通过编译,正确的构造函数应该是______。
#include<iostream.h>
class Sample
{
public:
int n;
const int con;
Sample(int m) {con=m+1;n=m;}
void disp( ) {cout<<"normal:n="<<n<<endl;}
void disp( )const {cout<<"static:n="<<n<<endl;}
};
void main( )
{
const Sample a (12);
Sample b (13);
a.disp( );
b.isp( );
cout<<a.n<<","<<b.con<<endl;
}
[填空题]main函数中发生编译错误的语句是 【12】 。
# include <iostream. h>
class A
{
public:
int a;
const int b:
A( ) :a(10) ,b(20) {
void fun( ) const
{
cout<<"a="<<a<<"/tb="<<b<<end1;
}
};
void main( )
A obj1;
const A * ptr = new A:
ptr = &obj1;
ptr->a=lO0;
ptr->fun( ),
}
[填空题]下列程序不能通过编译,应该在划线部分填写的语句是______。
#include<iostream.h>
#include<stdlib.h>
double Func(int a,int b,char ch)
{
double x;
switch(ch)
{
case’+’:
x=double(a)+b;
break;
case ’-’:
x=double(a)-b;
break;
case ’*’:
x=double(a)*b;
break;
case’/’:
if(B)x=double(a)/b;
else
exit(1);
break;
default:
exit(1);
}
______
}
void main( )
{
cout<<Func(32,6,’-’)<<",";
cout<<Func(32,6, ’*’)<<",";
cout<<Func(32,6,’/’)<<endl;
}
[填空题]参照函数模板的写法,完成非模板函数的定义,语句为______。
#include<iostream.h)
#include(string.h>
template(class T)
T min(T a,T b)
{
return(a<ba:b);
}
char*min(char*a,char*b)
{
}
void main( )
{
double a=1.23,b=3.45;
chars1[]=”abcd”,s2[]=”efg”;
cout<<min(a,b)<<rain(s1,s2)<(endl;
}
[填空题]在类定义时,如果没有定义任何构造函数,则编译器自动生成一个______构造函数。
[填空题]派生类构造函数的执行顺序是先执行【 】的构造函数,然后执行成员对象的构造 函数,最后执行【 】的构造函数。