[单选题]

设有如下程序:include class A{public:int i;display(){ cout<<"class A/n"; }};c

设有如下程序:#include <iostream. h>class A{public:int i;display(){ cout<<"class A/n"; }};class B{public:int i;display(){ cout<<"class B/n"; }};class C: public: A, public: B{int j;public:int i;show(){ j=i*i; display(); }};void main(){C demo;demo. show();}则主程序运行时,将( )。

A.因为变量i的重复定义而报错

B.因为对象demo间接调用display函数时产生歧义性而报错

C.因为类定义的语法错误而不能运行

D.没有语法错误,能够正常输出结果

参考答案与解析:

相关试题

有如下程序段:public class Parent {public int a

[单选题]有如下程序段: public class Parent { public int addValue (int a,intB){ int s; s=a+b; return 3; } } class Child extends Parent {} 则下列选项中,可以正确加入类Child中且父类的方法不会被覆盖的是( )。A.int addValue (int a,intB){//do something...}B.public void addValue() {//do something...}C

  • 查看答案
  • 有如下程序: class Base{ public: int data; };

    [单选题]有如下程序:class Base{public:int data;};class Derived1:public Base{};class Derived2:protected Base{};int main(){D.erived1 d1;D.erived2 d2;d1. data=0; //①d2. data=0; //②return 0;}下列关于程序编译结果的描述中,正确的是( )。A.) ①②皆无编译错误B.) ①有编译错误,②无编译错误C.) ①无编译错误,②有编译错误D.) ①②皆有

  • 查看答案
  • 有如下程序;public class MethTest{ static int

    [单选题]有如下程序; public class MethTest { static int Varl=100; int Var2=200; public static void main(String args[]) { Varl=10; MethTest Obj1=new MethTest(); MethTest Obj2=new MethTest(); Obj1.Varl++; System.out.println(Objl.Varl); Obj2.Varl++; System.out.printl

  • 查看答案
  • 设有如下程序:public class Sun{public static vo

    [单选题]设有如下程序: public class Sun { public static void main(String args[ ]) { int x, y; x-4; y=0; if(Math.pow(x,2)==16) y=x; if(Math.pow(x,2)<15) y=1/x; if(Math.pow(x,2)>15) y=(int)Math.pow(x,2)+1; System.out.println(y); } } 程序的运行结果是( )。A.4B.17C.18D.0.25

  • 查看答案
  • 设有如下程序:public class Sun{public static vo

    [单选题]设有如下程序: public class Sun { public static void main(String args[ ]) { int x,y; x=4; y=0; if(Math.pow(x,2)==16) y=x; if(Math.pow(x,2)<15) y=1/x; if(Math.pow(x,2)>15) y=(int)Math.pow(x,2)+1; System.out.println(y); } } 程序的运行结果是( )。A.4B.17C.18D.0.25

  • 查看答案
  • 设有如下程序:public class Sun{public static vo

    [单选题]设有如下程序: public class Sun { public static void main (String args[ ]) { int x,y; x= (int) Math.sqrt (2) /2+ (int) Math.random ()*2/2; y= (int) Math.sqrt (3) /3+ (int) Math.random ()*3/3; if (x>y) System.out.println ("x>y"); else if (x==y) System.out.

  • 查看答案
  • 设有如下程序:public class Sun{public static vo

    [单选题]设有如下程序: public class Sun { public static void main(String args[ ]) { int x,y; x=(int)Math.sqrt(2)/2+(int)Math.random()*2/2; y=(int)Math.sqrt(3)/3+(int)Math.random()*3/3; if (x>y) System.out.println("x>y"); else if (x==y) System.out.println("x=y")

  • 查看答案
  • 有如下程序public class Test{int a,b;Test ( ){

    [单选题]有如下程序 public class Test { int a,b; Test ( ) { a = 100; b = 200; } Test(int x, int y) { a = x; b = y; } public static void main(String args[]) { Test Obj1 = new Test(12,45); System.out.println("a = "Obj1.a+" b = "+ObB) ; Test Obj1 = new Test(); Sy

  • 查看答案
  • 有如下程序:#include void fun(int& x, int y){i

    [单选题]有如下程序:include void fun(int& x, int y){int t=x;x=y;y=t;}int main (){int有如下程序: #include <iostream> void fun(int& x, int y){int t=x;x=y;y=t;} int main () { int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; } 执行

  • 查看答案
  • 设有如下程序:import java.util.*;public class S

    [单选题]设有如下程序: import java.util.*; public class Sun { public static void main (String args[ ]) { int score; String a; Random r=new Random (); score=r.nextInt (4)+5; switch(score) { case 0: a="E"; break; case 1: a="D"; break; case 2: a="C"; break; case

  • 查看答案
  • 设有如下程序:#include class A{public:int i;dis