网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
下面程序段中,说法正确的是() class location{ public : int GetX(); }; class rectangle:private location { public: int GetW(); };
A.类rectangle的私有派生类是location
B.类rectangle中的public成员在类 location中是私有的
C.类location中的public成员在类rectangle中是不可访问的
D.viod f() { Rectangle r; int X=r .GetX(); } 其中int X = r .GetX();是非法语句
参考答案和解析
B
更多 “下面程序段中,说法正确的是() class location{ public : int GetX(); }; class rectangle:private location { public: int GetW(); };A.类rectangle的私有派生类是locationB.类rectangle中的public成员在类 location中是私有的C.类location中的public成员在类rectangle中是不可访问的D.viod f() { Rectangle r; int X=r .GetX(); } 其中int X = r .GetX();是非法语句” 相关考题
考题
请在mian函数中填空使下面程序的输出结果为1 1。 include class A { private:
请在mian函数中填空使下面程序的输出结果为1 1。include<iostream.h>class A{ private:int a;int b;public:A( ):a(0) ,b(1) { }void show( ) { cout < < a < < " " < < b;} };class B{ private:int a;int c;public:B( ):a(1),
考题
有以下程序:includeusing namespace std;class A{private:int a;public:A(int i){a=i
有以下程序: #include<iostream> using namespace std; class A {private: int a; public: A(int i) {a=i;} void disp() {cout<<a<<“,”;}}; class B {private: int b; public: B(int j) {b=j;} void disp() {cout<<b<<“,”;A.10,10,10B.10,12,14C.8,10,12D.8,12,10
考题
下面这个程序的结果是includeclass A{private:int a;public:void seta();int geta(
下面这个程序的结果是 #include<iostream.h> class A { private: int a; public: void seta();int geta();}; void A∷seta() {a=1;} int A∷geta() {return a;} class B { pnvate: int a; publiC: void sera();int geta();}; void B∷seta() {a = 2;} int B∷geta() {return a;} class C:public A,public B { private: int b; public: void display();}; void C∷display() { int b=geta(); cout<<b;} void main() { C c; c.seta(); c.display();}A.1B.2C.随机输出1或2D.程序有错
考题
下列程序中说明的公有成员是( ) 。class Location { int X; public: void init(int initX,int initY); private: int Y; public: int GetX(); int GetY(); };
A.init(int initX,int initY)B.XC.GetX(),GetY()D.B和C都是
考题
下面程序段中,说法正确的是( ) 。class location{ public : int GetX(); }; class rectangle:private location { public: int GetW(); };
A.类rectangle的私有派生类是locationB.类rectangle中的public成员在类location中是私有的C.类location中的public成员在类rectangle中是不可访问的D.viodf(){Rectangler;intX=r.GetX();}其中intX=r.GetX();是非法语句
考题
指出下面程序段中的错误,并说明出错原因【 】。class Location {int X, Y=20;protected:int zeroX, zeroY;int SetZero(int ZeroX, iht ZeroY);private:int length, height;public:float radius;void init(int initX,int initY);int GetX();Int GetY();};
考题
若有以下程序 include using namespace std; class A {private:int a; public: A(in
若有以下程序 #include <iostream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp() { cout<<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp() { cout<<b<<","; } }; class C: public B,public A { private: int c; public: C(int k):A(k-2),B(k+2) { c=k; } void disp() { A::disp(); B::disp(); cout<<c<<end1; } }; int main() { C obj(10); obj.disp(); return 0; } 程序执行后的输出结果是A.10,10,10B.10,12,14C.8,10,12D.8,12,10
考题
若有以下程序:includeusingnamespacestd;classA{private:int x; public:int x;void s
若有以下程序: #include<iostream> usingnamespacestd; classA { private: int x; public: int x; void setx(int i) { x=i; } int getx() { return x; } }; class B:public A { private: int m; public: int p; void setvalue (int a,int b,int C) { setx(A) ; z=b; m=c; } void display() { cout<<getx()<<","<<z<<","<<m<<end1; } }; int main() { B obj; obj.setvalue(2,3,4); obj.display(); return 0; } 程序运行以后的输出结果是A.产生语法错误B.2,3,4C.2,2,2D.4,3,2
考题
下面这个程序的结果是 include class A { private: int a; public: void seta( ) ;
下面这个程序的结果是#include<iostream.h>class A{private:int a;public:void seta( ) ;int geta( ) ;};void A: :seta( ){ a=1;}int A: :geta( ){ retum a;}class B{ private:int a;public:void seta( ) ;int geta( ) ;};void B: :seta( ){a=2;}int B: :geta( ){return a;}class C: public A,public B{ private:int b;public:void display( ) ;};void C: :display( ){ int b=geta( ) ;cout < < b;}void main( ){ C c;c. seta( ) ;c. display( ) ;}A.1B.2C.随机输出1或2D.程序有错
考题
下列程序的运行结果是 includeclass Location{private:int X.Y;public:void init(i
下列程序的运行结果是 #include<iostream.h> class Location{ private: int X.Y; public: void init(int=0,int=0); void valueX(int val){X=val;} int valueX( ){ return X;} void valueYA.5 0 6 4B.0 0 6 4C.5 0 6 2D.0 0 6 2
考题
有以下程序:include using namespace std;class A{private:int a;public:A (int i){a
有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A (int i) { a=i; } void disp() { cout<<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp() { cout<<b<<","; } }; class C : public B,public A { private: int c; public: C(int k) :A(k-2),B(k+2) { c=k; } void disp () { A::disp (); B::disp (); cout<<c<<endl; } }; int main () { C obi (10); obj.disp (); return 0; } 程序执行后的输出结果是A.10,10,10B.10,12,14C.8,10,12D.8,12,10
考题
下列程序的运行结果为 include class Location { protected: int X,Y;
下列程序的运行结果为 #include<iostream.h> class Location { protected: int X,Y; publiC: void SeX(int myx){X=myx;} void SetY(int myy){Y=myy;} void showxy( ) {cout<<"X=" <<X<<" " <<"Y"=<< Y<< endl;} }; Class Rectangle :public Location{A.X=3 Y=5 X=3 Y=5 H=4 W=6B.X=3 Y=5 X=3 Y=5 H=3 W=6C.X=3 Y=5 X=3 Y=4 H=4 W=6D.X=3 Y=5 X=3 Y=3 H=4 W=6
考题
若有以下程序:include using namespace std;class A{private:int x;public:int z;voi
若有以下程序:#include <iostream>using namespace std;class A{private: int x;public: int z; void setx(int i) { x=i; } int getx() { return x; }};class B: public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a); z=b; m=c; } void display() { cout<<getx()<<","<<z<<","<<m<<end1; }};int main(){ B obj; obj.setvalue(2,3,4); obj.display(); return 0;程序运行以后的输出结果是( )A.产生语法错误B.2,3,4C.2,2,2D.4,3,2
考题
下面程序的打印结果是【】。 include using namespace std; class Base { public:Base(i
下面程序的打印结果是【 】。include <iostream>using namespace std;class Base{public:Base(int x){a=x;}void show(){cout<<a;}private:int a;};class Derived : public Base{public:Derived(int i) :Base(i+1) ,b(i) { }void show(){cout<<b;}private:int b;};int main ( ){Base b(5) , *pb;Derived d(1);pb=d;pb->show();return 0;}
考题
根据注释内容在空白处填写适当内容。class Location{private:int X,Y;public:void init(int initX,int initY);int GetX( );int GetY( );};void Location::init(int initX,int initY){X=initX;Y=initY;}int Location::GetX( ){reutrn X;}int Location::GetY( ){reutrn Y;}include<iostream.h>void main( ){Location A1;A1.init(20,90);______ //定义一个指向A1的引用rA1cout<<rAl.GetX( )<<":"<<rAl.GetY( )<<endl;}
考题
有以下程序:includeusing namespace std;definePl 3.14Class Point{private:int x,y
有以下程序: #include<iostream> using namespace std; #definePl 3.14 Class Point {private: int x,y; public: Point(int a,intB) {X=a; y:b;} int getx() <return x;} int gety() {return y;}}; class Circle:public Point {priA.314B.157C.78.5D.153.86
考题
若有以下程序:include using namespace std;class A{private: int x;protected: int
若有以下程序: #include <iostream> using namespace std; class A { private: int x; protected: int y; public: int z; void setx(int i) { x=i; } int getx () { return x; }; class B : protected A { public: void setvalue(int a, int b, int c) { setx (a); y=b; z=c; } void display() { cout<<getx ( ) <<", "<<y<<", "<<z<<", "<<end1; } }; int main () { B obj; obj.setvalue(5, 6, 7); obj.display ( ); return 0; } 程序运行后的输出结果是( )。A.产生语法错误B.7,6,5C.5,6,7D.7,5,6
考题
若有以下程序:includeusing namespace std;class A{private:int a; public:void seta
若有以下程序: #include<iostream> using namespace std; class A { private: int a; public: void seta(int x) { a=x; } void showa() { cout<<a<<","; } }; class B { private: int b; public: void setb(int x) { b=x; } void showb() { cout<<b<<",”; } }; class C:pUblic A,private B { private: int c; public: void setc(int x,int y,int z) { c=z; seta(x); setb(y); } void showc() { showa(); showb(); cout<<c<<end1; } }; int main() { Cc; c.setc(1,2,3); c.showc(); retrun 0; } 程序执行后的输出结果是A.1,2,3B.1,1,1C.2,2,2D.3,3,3
考题
下面程序的结果是()。includeclass A{int a;public:A():a(1){}void showa(){cout
下面程序的结果是( )。 #include<iostream.h> class A { int a; public: A():a(1){} void showa(){cout<<a;} }; Class B { int a; public: B():a(2){} void showa(){cout<<a;} ); class C:public A,public B { int a; puA.1B.2C.3D.程序有错误
考题
若有以下程序:include using namespace std;class A{private:int a;public:A(int i){
若有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp () { cout<<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp () { cout<<b<<","; } }; class C : public B,public A { private: int c; public: C(int k):A(k-2),B(k+2) { c=k; } void disp () { A::disp(); B::disp(); cout<<c<<endl; } }; int main() { C obj(10); obj.disp(); return 0; }A.10,10,10B.10,12,14C.8,10,12D.8,12,10
考题
若有以下程序: #include 〈iostream〉 using namespace std; class A { private: int x; public: int z; void setx(int i) { x=i; } int getx () { return x; } }; class B : public A { private: int m; public: int p; void setvalue(int a,int b, int C) { setx (A) ; z=b; m=c; } void display() { cout〈〈getx()〈〈","〈〈z〈〈","〈〈m〈〈end1; } }; int main ( ) { B obj; obj.setvalue(2,3,4); obj.display(); return 0; } 程序运行以后的输出结果是( )。A.产生语法错误B.2,3,4C.2,2,2D.4,3,2
考题
若有以下程序:include using namespace std;define PI 3.14class Point{private: in
若有以下程序: #include <iostream> using namespace std; #define PI 3.14 class Point { private: int x,y; public: Point(int a,int b) { x=a; y=b; } int getx() { return x; } int gety() { return y; } }; class Circle : public Point { private: int r; public: Circle(int a, int b,int c) :Point(a,b) { r=c; } int getr() { return r; } double area() { return PI*r*r; } }; int main() { Circle c1(5,7,10); cout<<c1.area()<<end1; return 0; } 程序执行后的输出结果是( )。A.314B.157C.78.5D.153.86
考题
有以下程序:include using namespace std;define PI 3.14class Point{ private:int
有以下程序: #include <iostream> using namespace std; #define PI 3.14 class Point { private: int x,y; public: Point(int a,int b) { x=a; y=b; } int getx() { return x; }A.314B.157C.78.5D.153.86
考题
若有以下程序:includeusing namespace std;class A{private:int x;public:int z;void
若有以下程序:#include<iostream>using namespace std;class A {private: int x;public: int z; void setx(int i) { x=i; } int getx () { return x; }}:class B : public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a) ; z=b; m=c; } void display{) { cout<<getx ()<<", "<<z<<", "<<m<<end1; }};int main(){ B obj; obj. setvalue(2,3,4); obj.display(); return 0;} 程序运行以后的输出结果是A.产生语法错误B.2,3,4C.2,2,2D.4,3,2
考题
若有以下程序:include using namespace std;class A{private: int a;public: A(int
若有以下程序: #include <iost ream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp () { cout<<a<<", "; } }; class B { private:A.10,10,10B.10,12,14C.8,10,12D.8,12,10
考题
下列程序中说明的私有成员是 ______。class Location{int x;public: void init(int initX,int initY);private: int y;public: int SetX();Int SetY();A.xB.yC.SetX(),SetY()D.ABC都是
考题
public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()A、 public class Circle implements Shape { private int radius; }B、 public abstract class Circle extends Shape { private int radius; }C、 public class Circle extends Shape { private int radius; public void draw(); }D、 public abstract class Circle implements Shape { private int radius; public void draw(); }E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
考题
多选题public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()Apublic class Circle implements Shape { private int radius; }Bpublic abstract class Circle extends Shape { private int radius; }Cpublic class Circle extends Shape { private int radius; public void draw(); }Dpublic abstract class Circle implements Shape { private int radius; public void draw(); }Epublic class Circle extends Shape { private int radius;public void draw() {/* code here */} }Fpublic abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
热门标签
最新试卷