A.赞科夫
B.皮亚杰
C.布鲁纳
D.根舍因
第1题
在下列程序的划线处应填入的语句是()。 class Person { private int a: } public class Man extends Person{ public int b; public static void main(String arg []){ Person p=newPerson(); Man t=new Man(); int i; _________________ } }
A.i=w;
B.i=b;
C.i=P.a;
D.i=t.b;
第2题
在下列程序的划线处应填入的语句是 () class Person { private int a; } public class Man extends Person { public int b public static void main(String arg[]) { Person P=new Person(); Man t=new Man(); int i; ______ } }
A.i=w;
B.i=b;
C.i=p.a;
D.i=t,b;
第3题
A.i = w;
B.i = b;
C.i = p.a;
D.i = t.b;
第4题
下列程序编译错误,是由于划线处缺少某个语句,该语句是______。
include<iostream.h>
class A
{
private:
int numl;
public:
A():numl(0){}
A(int i):numl(i){}
};
class B
{
private:
int num2;
public:
B():num2(0){}
B(int i):num2(i){}
int my_math(A obj1, B obj2);
};
int B::my_math(A obj1,B obj2)
{
return(obj1.numl+obj2.num2);
}
void main(void)
{
A objl(4);
B obj,obj2(5);
cout<<"obj1+obj2:"<<obj.my_math(obj1,obj2);
}
第5题
为完成下面的程序,应在划线处填入的语句是 #include<iostream> using namespace std; class Base { private: int x; public: Base(int i) { x=i; } ~Base(){} }; class Derived:public Base { public: ______ //完成类Derive构造函数的定义 }; int main() { Derived obj; return 0; }
A.Derived(int i):Base(i){}
B.Derived(){}
C.Void Derived (int i):Base(i){}
D.Denved(int i){Base(i);}
第6题
为完成下面的程序,应在划线处填入的语句是 #include<iostream> using namespace std; class Base { private: int x; public: Base (int i) { x=i; } ~Base(){} }; class Derived:public Base { public: ______________//完成类Derive构造函数的定义 }; int main() { Derived Obj; return 0; }
A.Derived(int i):Base(i){}
B.Derived(){}
C.void Derived (int i):Base(i){}
D.Derived(int i){Base(i);}
第7题
为完成下面的程序,应在划线处填入的语句是()。 #include <iostream> using namespace std; class Base { private: int x; public: Base(int i) { x=i; } ~Base(){} }; class Derived : public Base { public: _______________ //完成类Derive构造函数的定义 }; int main() { Derived Obj; return 0; }
A.Derived(int i):Base(i){}
B.Derived(){}
C.voidDerived(int i):Base(0){}
D.Derived(int i){Base(i);}
第8题
下列程序中需要清理动态分配的数组,划线处应有的语句是_______。
include<iostream.h>
class person
{
int age,tall;
public:
person(){age=0;tall=40;cout<<"A baby is born."<<endl;}
person(int i){age=i;tall=40;cout<<"A old person."<<endl;}
person(int i,int j){age=i;tall=j;cout<<"a old person with tall."<<endl;)
~person(){cout<<"person dead."<<endl;}
void show()
{
cout<<"age="<<age<<",tall="<<tall<<endl;
}
};
void main()
{
person*ptr;
ptr=new person[3];
ptr[0]=person();
ptr[1]=person(18);
ptr[2]=person(20,120);
for(int i=0;i<3;i++)
ptr[i].show();
______
}
第9题
为使该程序执行结果为10,那么应该在程序划线处填入的语句是()。 #include<iostream> using namespace std; class MyClass { public: MyClass (int a) { x=a; } ___________ //取x值 private: int x; }; int main() { MyClass my(10); cout<<my.GetNum()<<end1; return 0; }
A.return x;
B.int GetNum(){ return x;}
C.intreturn x;
D.void GetNum(){return x;}
第10题
为了使程序的输出的正确结果为: Now is 2004.7.10 10:10:10. 那么应在下列程序划线处填入的正确语句是()。 那么应在下列程序划线处填入的正确语句是()。 #include <iostream> using namespace std; class TIME; class DATE { public: DATE(int y=2004,int m=1,int d=1) { year=y; month=m; day=d; } friend void DateTime(DATE &d, TIME &t); private: int year, month, day; }; class TIME { public: TIME(iht h=0, int m=0,int s=0) { hour=h; minute=m; second=s; } friend void DateTime(DATE &d,TIME &t); private: int hour,minute, second; }; ______________________ //函数 DateTime 的首部 { cout<<"Now is"<<d.year<<'.'<<d.month<<'.'<<d.day<< ' '<<t.hour<<":"<<t.minute<<':'<<t.second<<'.'<<end1; } int main () { DATE d(2004,7,10); TIME t(10, 10, 10); DateTime(d,t); return 0; }
A.void DateTime(DATE &d,TIME &t)
B.void TIME::DateTime(DATE &d,TIME &t) const
C.friend void DateTime(DATE &d,TIME &t)
D.void DATE::DateTime(DATE &d,TIME &t)
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!