更多"在MyClass类的定义中,对赋值运算符二进行重载。请将画线处缺失的部"的相关试题:
[填空题]在MyClass类的定义中,对赋值运算符:进行重载。请将画线处缺失的部分补充完整。
【13】 MyClass::operator=(const MyClass& rhs)
{
if (this==&rhs) return *this;
value = rhs.value;
return *this;
}
[填空题]在MyClass类的定义中,对赋值运算符:进行重载。请将画线处缺失的部分补充完整。
【13】 MyClass::operator=(const MyClass& rhs)
if (this==&rhs) return *this;
value = rhs.value;
return *this;
[填空题]在MyClass类的定义中,对赋值运算符"="进行重载。请将画线处缺失的部分补充完整。【 】 MyClass::operator==(const MyClass&rhs)
{
if(this==&rhs
)return*this;
value=rhs.value;
retum*this;
}
[单项选择]类MyClass的定义如下,若要对value赋值,则下面语句正确的是( )。
class MyClass
public:
MyClass( )
MyClass( )(int I)value=new mki;
nt *value;
;
A. MyClass my; my.value=10;
B. MyClass my; *my.value=10;
C. MyClass my; my.*value=10;
D. MyClass my(10);
[填空题]
请完善程序(程序文件名:Java_3.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。
[题目要求]
统计一个英文文本字符串包含的英文元音字母的个数,使程序的运行结果如下:
The text contained vowels:88
源程序:
public class Java_3 {
public static
void main(String[] args) {
String text = " Beijing, the Capital City, is the political,
"
+ "cultural
and diplomatic centre of China. It has"
+ "become a modern international cosmopolitan
city"
+ " with
more than 11 million people. The Capital"
+ " International Airport, 23.5 km from the city
centre,"
+
"is China’s largest and most advanced airport. " ;
int vowels =0;
int (1)
= text.length( );
for(int i = 0;i<textLength; i++) {
char
ch=Character.toLowerCase( text. (2) );
if(ch==’a’||ch==’e’||ch==’i’||ch==’o’||ch==’u’)
[填空题]请完善程序(程序文件名:Java_1.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。
题目要求:
完成程序并运行,得到的结果如下:
*****在初始化之前*****
x=0 y=0 z=0
*****在初始化中*****
x=20 y=30 z=5
*****在初始化之后*****
x=20 y=30 z=0
源程序:
class Variable
int x=0, y=0, z=0; //类变量
void init(int x, int y)
(1) =x;
this.y=y;
int z=5;//局部变量
System.out.println("*****在初始化中*****");
System.out.println("x="+x+"y="+y+"z="+z);
public class Java_1
public static void main(String[]args)
Variable v=new (2) ;
System.out.println("*****在初始化之前*****");
System.out.println("x="+v.x+"y="+v.y+"z="+v.z);
v.init(20,30);
System.out.println("*****在初始化之后*****");
System.out.println("x="+v.x+"y="+v.y+"z="+v.z);
[填空题]请完善程序(程序文件名:Java_2.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。
题目要求:
Java_2.java程序的功能是在一个整型数组中查找指定的数,找到后将该数字及其位置打印出来。完成后并运行,所得到的结果为:
Found 12 at index 4
源程序:
public class Java_2
public static void main(String[]args)
int[]arrayOfInts=32, 87, 3, 589, 12, 1076, 2000, 8, 622, 127;
int searchfor=12;
int i=0;
boolean foundIt=false;
for(;i< (1) ; i++)
if(arrayOfInts[i]==searchfor)
foundlt= (2) ;
break;
if( (3) )System.out.println("Found"+searchfor+"at index"+i);
else System.out.println(searchfor+"not in the array");