下列程序中说明的私有成员是 ______。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都是
下列程序中说明的私有成员是 ______。
class Location
{
int x;
public: void init(int initX,int initY);
private: int y;
public: int SetX();
Int SetY();
A.x
B.y
C.SetX(),SetY()
D.ABC都是
相关考题:
有如下类声明:class MyClass{int i;private: int j;protected:int k;public:int m, n;};其中,私有成员的数量为 【 9 】 。
下列程序的输出结果是非曲直【 】。includeclass base{ int x, y;public: base(int i, 下列程序的输出结果是非曲直【 】。include<iostream, h>class base{int x, y;public:base(int i, int j){x=i; y=j;}virtual int add(){return x+ y;}};class three: public base{int z;public:three(int i, int j, int k) :base(i, j){z=k; }int add() { return (base:: add()+z); }};void main(){three * q=new three(lO,20,30);cout<<q->add()<<end1;}
有如下程序:includeusing namespace std;class Base{int x;public:Base(int n=0):x(n 有如下程序: #include<iostream> using namespace std; class Base{ int x; public: Base(int n=0):x(n){cout<<n;} int getX( )const{return x;} }; class Derived:public Base{ int y; public: Derived(int m,int n):y(m),Base(n){tout<<m;} Derived(int m):y(m){cout<<m;} }; int main( ){ Derived dl(3),d2(5,7); return 0; } 程序的输出结果是A.375B.357C.0375D.0357
有如下类声明: class XA{ int X; public: XA(int n){x=n;} }; class XB:public XA{ int y; public: XB(int a,int b); }; 在构造函数XB的下列定义中,正确的是( )。A.XB::XB(inta,int b):x(a),y(b){}B.XB::XB(int a,int b):XA(a),y(b){}C.XB::XB(int a,int b):x(a),XB(b){}D.XB::XB(int a,int b):XA(a),XB(b){}
程序的输出结果是【 】。 include using namespace std; class A{ int x; public: A(int 程序的输出结果是【 】。include <iostream>using namespace std;class A{int x;public:A(int x=1):x(x){cout<<x;}};void main(){A a,b(2),c(3);}
下列程序中说明的公有成员是( ) 。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 {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();};
在下列的程序的横线处填上适当的语句,使该程序的输出为12。 includeusing namespace st 在下列的程序的横线处填上适当的语句,使该程序的输出为12。include<iostream>using namespace std;class TestClass{public:int a,b;TestClass(int i,int j){a=i;b=j;}};class TestClass1:public TestClass{int a;public:TestClass1(int x):TestClass(x,x+1){}void show(){______;//输出基类数据成员a的值?cout<<b<<endl;}};int main(){TestClass1 d(1);d.show();return 0;}
在下面的程序的横线处填上适当的语句,使该程序的输出为12。include 〈iostream〉using namespace std;class Base{public:int a;Base(int i) { a=i;}};class Derived : public Base{int a;public:Derived(int x) : Base(x),b(x+1) {}void show(){【 】; //输出基类数据成员a的值cout〈〈b〈〈end1;}};int main(){Derived d(1);d.show();return 0;}
若有以下程序: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
有如下类声明: class XA { int x; public: XA(int n){x=n;} }; class XB:public XA { int y; public: XB(int a,int b); }; 在构造函数XB的下列定义中,正确的是A.XB::XB(int a,int b):x(a),y(b){}B.XB::XB(int a,int b):XA(a),y(b){}C.XB::XB(int a,int b):x(a),XB(b){}D.XB::XB(int a,int b):XA(a),XB(b){}
完成下列类的构造函数,初始化语句为______。 include class Test { private: int x,y 完成下列类的构造函数,初始化语句为______。include<iostream.h>class Test{private:int x,y;public:void Test(int initx,int inity){______}void printx( ){cout<<x<<"-"<<y<<"="<<x-y;}};void main( ){Test x(300,200);x.printx( );}
下列程序的运行结果是inClUdeclass Location{private:int X,Y;pubhc:void init(int 下列程序的运行结果是 #inClUde<iostream.h> class Location{ private: int X,Y; pubhc: void init(int=0,int=0) ; void valueX(int val) {X=val;} int valueX( ) {retum X;} void valueY(int val) {Y=val;} int valueY( ) {retum Y;}};void Location: :init(int initX,int initY) { X=initX; Y=initY;} Void main( ) { Location A,B; A. init( ) ; A. valueX(5) ; cout < < A. valueX( ) < < endl < < A. valueY( ) < < endl; B. init(6,2) ; B. valueY(4) ; cout < < B. valueX( ) < < endl < < B. valueY( ) < < endl;}A.5B.0C.5D.0 0 0 0 0 6 6 6 6 4 4 2 2
有如下类说明: class TestClass{ int x; public: TestClass(int n){x=n;} }; class TestClass1:public TestClass{ int y; public: TestClass1(int a,int b); }; 在构造函数TestClass1的下列定义中,正确的是( )。A.TestClass1::TestClass1 (int a,int b):x(a),y(b){}B.TestClass1::TestClass1 (int a,int b):TestClass(a),y(b){}C.TestClass1::TestClass1 (int a,int b):x(a),TestClass1(b){}D.TestClass1::TestClass1 (int a,int b):TestClass(a),TestClass1(b){}
以下程序的执行结果是______。 include class A{ int a: public: void seta(int x) { 以下程序的执行结果是______。include<iostream.h>class A{int a:public:void seta(int x) {a=x;}void showa() {cout<<a<<end1;}};class B{int b;public:void setb(int x) {b=x;}void showb(){cout<<b<<end1;}};
下列程序的运行结果是 includeclassLocation{ private: int X,Y; public: void init 下列程序的运行结果是 #include<iostram.h> classLocation{ private: int X,Y; public: void init(int=0, int=0) ; void valueX(int val){X=val:} int valueX(){return X;} void valueY(int val){Y=val;} int valueY(){returnY;}}; void Location∷init(int initX,int initY) { X=initX; Y=initY;} void main() { LocationA,B; A.init(); A.ValueX(5); cout <<A.ValUeX() <<endl<<A,valueY() <<endl; B.init(6,2); B.valueY(4) ; cout<<B.valueX() <<endl<<B.valueY() <<endl;}A.5 0 6 4B.0 0 6 4C.5 0 6 2D.0 0 6 2
在下列源代码文件Test.java中,正确定义类的代码是( )。A.pblic class test { public int x=0; public test(int x) { this. x=x;} }B.public class Test { public int x=0; public Test(int x) { this. x=x;} }C.public class Test extends T1,T2{ public int x = 0; public Test(int x){ this. x = x; } }D.protected class Test extends T2{ public int x = 0; public Test(int x) { this. x = x; } }
根据注释内容在空白处填写适当内容。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;}
下列程序在构造函数和析构函数中申请和释放类的私有成员,请完成该程序。class Myclas{int *x;public:MyClas(int n);~MyClas();};MyClas::MyClas(intn){【 】;}MyClas::~MyClas(){【 】;}
下列程序在构造函数和析构函数中申请和释放类的私有成员,请完成该类的实现。class Myclass {public:Myclass(int num);~ Myclass( );public:int *p;};Myclass: :Myclass( int hum) {【 】Myclass:: ~ Myelass( ) {【 】;}。
有如下类声明: class XA { int x; public: XA(int n) {x=n;} }; class XB: public XA{ int y; public: XB(int a,int b); };在构造函数XB的下列定义中,正确的是______。A.XB:: XB(int a, int b):x(a),y(b) { }B.XB::XB(int a, int b):XA(a),y(b){}C.XB::XB(int a,int b):x(a),XB(b)i}D.XB::XB(int a,int b):XA(a),XB(b){}
有下列程序:includeusing namespace std;class TestClass{int a;public:TestClass(in 有下列程序: #include<iostream> using namespace std; class TestClass { int a; public: TestClass(int x)<a=x;} void show(){cout<<a;} }; class TestClass1:publicTestClass { int b; public: TestClaA.5B.1C.0D.2
下列程序的运行结果是( )。 #includeiostream.h class Loeation{ private: int X,Y; public: void init(int=0,int=0); void valueX(int val){X=val;} int valueX{returnx;} void valueY(int val){Y=val;} int valueY{return Y;}}; void Location::init(int initX,int initY) {X=initX; Y=initY4} void main(X {Location A,B; A.init; B.value X(5); coutA.value XendlA.value Yendl; B.init(6,2); B.value Y(4); eoutB.value XendlB.value Yendl; }A.5 0 6 4B.0 0 6 4C.5 0 6 2D.0 0 6 2
在下列源代码文件Test.java中, ( )是正确的类定义。A.public class test{B.public class Test{ public int x=0;public int x=0; public test (intx) public Test (int x){ {this.x=x; this.x=x;} }} }C.public class Test extends T1,T2{D.protected class Test extends T2{ public int=0;public int x=0; public Test(int x){Public Test (int x){ this.x=x;this.x=x: }} }}
在下列源代码文件Test.java中,哪个选项是正确的类定义? ( )A.public class test { public int x=0; public test(int x) { this.x=x; } }B.public class Test { public int x=0; public Test(int x) { this.x=x; } }C.public class Test extends Ti,T2 { public int x=0; public Test(int x) { this.x=x; } }D.protected class Test extends T2 { public int x=0; public Test(int x) { this.x=x; } }
下列程序的输出结果是______。 include class base { int x,y; public: base(int i,i 下列程序的输出结果是______。include<iostream.h>class base{int x,y;public:base(int i,int j){x=i;y=j;}virtual int add( ){return x+y;}};class three:public base{int z;public:three(int i,int j,int k):base(i,j){z=k;)int add( ){return(base::add( )+z);}};void main( ){three*q=new three(10,20,30);cout<<q->add( )<<endl;}
给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test { public void cal(int x, int y, int z) { } //A } A、public int cal(int x,int y,float z){return 0;}B、public int cal(int x,int y,int z){return 0;}C、public void cal(int x,int z){}D、public viod cal(int z,int y,int x){}