若有如下类定义:class Shape {public:virtual void Draw()=0;};则下列关于Shape类的叙述中,正确的是()。
A. 类Shape是虚基类
B.类Shape是抽象类
C.类Shape中的Draw函数声明有误
D.“Shape s;”能建立Shape的对象s
A. 类Shape是虚基类
B.类Shape是抽象类
C.类Shape中的Draw函数声明有误
D.“Shape s;”能建立Shape的对象s
A. 类中有1个公有数据成员
B.类中有1个私有数据成员
C.类中有2个私有数据成员
D.数据成员name的访问权限未知
若类A和类B的定义如下: class A { int i,j; public: void get(); //… } ; class B:A//默认为私有派生 { int k; public: void make(); //… }; void B::make() { k=i*j; } 则上述定义中, ()是非法的表达式。
A.void get();
B.int k;
C.void make();
D.k=i*j;
如下Java的类定义:
public class Example{
static int X[]=new int[15];
public static void main(String args[]){
System.out.printin(x[5]);
}
}
说法正确的是______。
A.编译时出错 B.运行时出错
C.输出0 D.无输出
A.void get();
B. int k;
C. void make();
D. k=I*j;
A.ing
B.staticint
C.intPoint::
D.staticintPoint::
如下Java的类定义:
publiC class Example{
publ ic StatiC VOid main(String args[]){
StatiC int x[]=new int[15]j
System.out.printin(X[5])j
}
)
说法正确的是______。
A.编译时出错 B.运行时出错
C.输出结果为0 D.无输出
A.BBBB
B.BBAA
C.AABB
D.AAAA
A. cout<
B.cout<
C.cout<
D.cout<
A.private void fun(int n ){ //...}
B.void fun (int n ){ //... }
C.protected void fun (int n ) { //... }
D.public void fun (int n ) { //... }
类A及其派生类B定义如下:class A{ public int getIno(int a) { return a; }}public class B extends A{ public loat getIno(int b) { return b; } public static void main(String[]args) { A a=new A(); B b=new B(); System.out.println(a.getIno(3)+","+b.getIno(5)); }}关于上述程序代码的叙述中正确的是 ()
A.第10行不能通过编译
B.程序通过编译,输出结果为:3,3
C.程序通过编译,输出结果为3,5
D.程序通过编译,输出结果为:5,5
有如下类定义:
class Bag {
public:
Bag(int p,char s='M'):price(p),size(s) { count++; }
~Bag() { count--; }
int GetPrice() { return price; }
int GetPrice() const { return price; }
void SetPrice(int val) const { price=val; }
private:
int price;
char size;
static int count;
};
下列关于类成员的叙述中,正确的是()。
A. 成员函数GetPrice存在重定义
B.构造函数的参数不能设置默认值
C.析构函数中不能访问静态数据成员
D.成员函数SetPrice不能定义为常函数