第1题
补充完整下面的类定义:
class XCH{
char*a;
public:
XCH(char*a A) { //构造函数
a=new char[strlen(aA) +1];
strcpy(a,aA) ;
}
XCH&operator=(const XCH&x){//重载赋值函数
delete[ ]a;
a=new char[strlen(x.A) +1];
strcpy(a,x.A) ;
______;
}
~XCH(){delete[ ]a;}
};
第2题
补充完整下面的类定义:
class XCH{
char*a:
public:
XCH(char球an){ //构造函数
a=new char[strlen(aft)+1];
strcpy(a,aA);
}
XCH&operator=(const XCH&x){ //重载赋值函数
delete[]a;
a=new char[strlen(X.A)+1];
strcpy(a,x.A);
【 】
}
一XCH(){delete[]a;}
};
第3题
(13 )补充完整下面的类定义:
const double PI=3 .14;
class Circle{ // 圆形物体的抽象基类
protected:
double r; // 半径
public:
Circle (double radius=0 ) : r (radius ) {}
【 13 】 ; // 计算圆形物体表面积的纯虚函数声明
};
class Cylinder:public Circle { // 圆柱体类
double h; // 高度
public:
Cylindr (double radius=0, doubli height=0 ) :
Circle (radius ) , h (height ) {}
Virtual double Area () { // 计算圆柱体的表面积
return 2*PI*r* (r+h ) ;
}
};
第4题
类Test定义如下: public class Test{ public static void main(String args[]) { String sty=new String("abcde"); char ch[]={A,B,C,D,E}; ml(str,ch); System.out.print(str+","); System.out.println(ch); } public static void ml(String s,char ch[]) { s="Hello"; ch[3]=Z; } } 那么程序的执行结果为:【 】
第5题
请将下列类定义补充完整。
class Base{public:void fun(){cout<<"Base::fun"<<end;}};
class Derived:public Base
{
public:
void fun()
{
【 】//显式调用基类的fun函数
cout<<"Derived::fun"<<endl;
}
};
第6题
请将下列类定义补充完整。
class Base{public:void fun(){cout<<"Base::fun"<<endl;}};
class Derived:public Base
{
public:
void fun(){
______//显式调用基类的fun函数
cout<<"Derived::fun"<<endl;
}
};
第7题
请将下列类定义补充完整
class Base{public: void fun(){cout<<"Base::fun"<<end1;}};
class Derived:public Base
{
public:
void fun(){
______//显式调用基类的fun函数
cout<<"Derived::fun"<<end1;
}
};
第8题
请将下列类定义补充完整。
class Base{public:void fun(){tout<<"Base::fun"<<endl;}};
class Derived:public Base
{
public:
void fun()
{
______//显示调用基类的fun函数
cout<<"Derived::fun"<<endl;
};
第9题
下列是一个类的定义程序段,请补充完整。 public class My Class { int x,y; MyClass(int i,【 】) { x=i;y=j; } }
第10题
请将下列类定义补充完整。
class Base{public:void fun(){cout<<"Base∷fun"<<end1;}};
c1ass DehVed:public Base
{
public:
void fun(){
______ ∥显式调用基类的fun函数
cout<<"Derived∷fun"<<endl;
}
};
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!