给出如下代码,如何使成员变量 m 被函数fun()直接访问? () class Test{ private int m;   public static void fun() {     // some code...   } }A.将private int m 改为 static int mB.将private int m 改为public int mC.将private int m 改为protected int mD.将private int m 改为 int m

给出如下代码,如何使成员变量 m 被函数fun()直接访问? () class Test{ private int m;   public static void fun() {     // some code...   } }

A.将private int m 改为 static int m

B.将private int m 改为public int m

C.将private int m 改为protected int m

D.将private int m 改为 int m


参考答案和解析
static int m;

相关考题:

有如下类声明:class MyClass{int i;private: int j;protected:int k;public:int m, n;};其中,私有成员的数量为 【 9 】 。

能将程序补充完整的选项是( )。class Person{ private int a; public int change(int m){ return m; }}public class Teacher extends Person{ public int b; public static void main(String arg[]) { Person p = new Person(); Teacher t = new Teacher(); int i; ______ }} B.A.i=mB.i=bC. i=p.aD.i=p. change(50)

能将程序补充完整的选项是______。 class Person{ private int a; phblic int change(int m){return m;} } public class Teacher extends Person{ public int b; public static void main(String arg[ ]){ Person p=new Person( ); Teacher t=new Teacher( ); int i; ______; } }A.i=mB.i=bC.i=p.aD.i=p.change(50)

已知如下类定义: class Base { public Base (){ //... } public Base ( int m ){ //... } protected void fun( int n ){ //... } } public class Child extends Base{ // member methods } 如下哪句可以正确地加入子类中?() A.private void fun( int n ){ //...}B.void fun ( int n ){ //... }C.protected void fun ( int n ) { //... }D.public void fun ( int n ) { //... }

已知如下类说明: public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); // 程序代码… } } 如下哪个使用是正确的?() A.t.fB.this.nC.Test.mD.Test.n

若有以下程序:includeusing namespace std;class sample{private: int x;public: sam 若有以下程序: #include <iostream> using namespace std; class sample { private: int x; public: sample() { } void setx(int i) { x=i; } friend int fun(sample B[],int n) { int m=O; for (int i=O; i<n; i++) { if(B[i].x>m) m=B [i].x; } return m; } }; int main ( ) { sample A[10]; int arr[]={90,87,42,78,97,84,60,55,78,65}; for (int i=O;i<10;i++) A[i]. setx (arr[i]); cout<<fun(A, 10)<<end1; return 0; } 该程序运行后的输出结果是( )。A.97B.84C.90D.78

给出下列代码,如何使成员变量m被方法fun( )直接访问?Class Test{private int m;public static void fun( ){} }A.将private int m改为protected int mB.将private int m改为public int mC.将private int m改为static int mD.将private int m改为int m

以下程序的执行结果是【】。include class B{public:B(){}B(int i.int j); void printb 以下程序的执行结果是【 】。include <iostream.h>class B{public:B(){}B(int i.int j);void printb();private:int a,b;};class A{public:A() { }A(int i,int j);void printa();private:B c;};A:: A(int i,int j):c(i, j){ }void A:: pfinta(){c. printb();}B::B(int i,int j){a=i;b=j;}void B::printb(){cout<<"a="<<a<<",b="<<b<<end1;}void main(){A m(7,9);m. printa();}

给出下列代码,如何使成员变量m被方法fun( )直接访问? class Test{ private int m; public static void fun( ){ … } }A.将private int m改为protected int mB.将private int m改为public int mC.将private int m改为static iD.将private int m改为int m

若有以下程序: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

已知有下列类的说明,则下列哪个语句是正确的?public class Test { private float f=1.0f; int m=12; static int n=1; public static void main(String arg[]) { Test t= new Test(); }}A.t.f;B.this. nC.Test.m;D.Test.f;

若有以下程序: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 class Myclass { public: void GetSum(int a) 下列程序的执行结果是【 】。include < iostream. h>class Myclass{public:void GetSum(int a)static int Sum:private:int A;};int Myclass:: Sum =10; //必须在类外部对静态数据成员初始化void Myelass: :GetSum(int a){A=a;Sum+=A;}void PrintSum(Myclass A){cout<<"Sum="<<A.Sum<<end1;}void main( ){Myclass M,N;M. GetSum(3)N. GetSum(7)PrintSum(M);}

有如下类定义: class Test { private int x; public int y; public void setX (int m) {x=m;} public int getX( ) {return x;} }现用Test t=new Text();生成一个对象t,则如下语句中,错误的是( )。A.t.x=10;B.t.y=10;C.t. setX(10);D.int m=t.getX( );

有如下类声明: class TestClass int i; private:int j; protected:int k; public:int m,n; 其中,私有成员的数量为( )。A.0B.1C.2D.3

类中包含了一个静态成员函数,则main函数中和P.fl(P);语句具有同样功能的语句为______。include<iostream.h>class M{public:M(int A){A=a;B+=a;}static void fl(M m);private:int A;static int B;};void M::f1(M m){cout<<"A="<<m.A<<endl;cout<<"B="<<m.B<<endl;}int M::B=10;void main( ){M P(5);P.f1(P);}

若有以下程序:include using namespace std;class Base{ int x;protected: int y;pub 若有以下程序: #include <iostream> using namespace std; class Base { int x; protected: int y; public: int z; void setx(int i) { x=i; } int getx ( ) { return x; } }; class Inherit : private Base { private: int m; public: int p; void setvalue(int a,int b,int c, int d) { setx(a) ; y=b; z=c; m=d; } void display() { cout<<getx ()<<", "<<y<<", "<<z<<", "<<m<<end1; } }; int main() { Inherit A; A.setvalue(1,2,3,4); A.display(); return 0; } 程序运行后的输出结果是( )。A.1,2,3,4B.产生语法错误C.4,3,2,1D.2,3,4,5

若有以下程序:include using namespace std;class Base{private: int a,b;public: Ba 若有以下程序: #include <iostream> using namespace std; class Base { private: int a,b; public: Base(int x, int y) { a=x; b=y; } void show() { cout<<a<<", "<<b<<end1; } }; class Derive : public Base { private: int c, d; public: Derive(int x, int y, int z,int m):Base(x,y) { c=z; d=m; } void show() { cout<<c<<", "<<d<<end1; } }; int main ( ) { Base b(50,50) ,*pb; Derive d(10,20,30,40); pb=d; pb->show {); return 0; }A.10,20B.30,40C.20,30D.50,50

给出下面的程序代码如何使成员变量a被函数m()直接访问呢?()A.将private floata改为protected floataB.将private floata改为public floataC.将private floata改为static floataD.将private floata改为floata

若有以下程序: #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

下面哪个方法是 public void example(){...} 的重载方法?A、private void example( int m){...}B、public int example(){...}C、public void example2(){...}D、public int example(int m, float f){...}

若有以下程序: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

类中包含了一个静态成员函数,则main函数中和P.f1(P);语句具有同样功能的语句为______。include<iostream.h>class M{public:M(int A){A=a;B+=a;}static void f1(M m);private:int A;static int B;};void M::f1(M m){cout<<“A=“<<m.A((end1;cout<<“B=”<<m.B<<en

Which are syntactically valid statement at// point x?()     class Person {     private int a;  public int change(int m){  return m;  }     }  public class Teacher extends Person {     public int b;  public static void main(String arg[]){     Person p = new Person();     Teacher t = new Teacher();    int i;  // point x     }    } A、 i = m;B、 i = b;C、 i = p.a;D、 i = p.change(30);E、 i = t.b.

Which three form part of correct array declarations?()  A、 public int a []B、 static int [] aC、 public [] int aD、 private int a [3]E、 private int [3] a []F、 public final int [] a

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 */ } }

( 难度:中等)下面哪个函数是 public void example(){...} 的重载函数?A.private void example( int m){...}B.public int example(){...}C.public void example2(){...}D.public int example ( int m, float f){...}E.public int example ( int m, float f, int cc){...}