2043 ooptest

2043 ooptest

1

How does private visibility affect attributes and operations?

  • A、

    Makes them accessible only to other classes in the same package

  • B、

    Makes them accessible only to the class itself and its friends

  • C、

    Makes them accessible to all clients

  • D、

    Makes them accessible only to the class itself

  • E、

    Makes them accessible only to subcalsses

B

填空题

1

C++ programmers concentrate on creating their own user-defined types called class .

2

If required, member functions can be declared constant member functions as to prevent even an inadvertent change in the data members.

3

A variable that is part of a class, yet is not part of an object of that class, is called a static member.

4

Only one copy of a static data member exists for the entire class.

5

#include

using namespace std;

(1)Class OOPClass{

(2) public

void displayMessage() {

cout << “Welcome to the OOP World!\n”;

}

};

int main() {

​ (3) OOPClass myOOPClass ; // creating an object named myOOPClass

​ (4)myOOPClass.displayMessage() ;

return 0;

}

The output is: Welcome to the OOP World!

判断题

  1. The return type of a constructor in C++ is void. F

在C++中构造函数返回的类型可以是空的,也可以是其他类型

2.Member function cannot be overloaded. F

成员函数可以被重载

3.Structures in C++ can have member functions also. T

**C++中的结构体和C不一样。 默认情况下,结构的基数默认是公共继承(public)的,而默认情况下,类的基数则是私有(private)的继承。 结构无法封装因为成员函数只能是public,而类可以封装。 默认情况下,用关键字class定义的类的成员是私有的。默认情况下,用关键字struct或union定义的类的成员是公共的。 **

4.Structure members are private by default. F

如上题解答,故4题错

5.Only constant member function can be called for constant object. T*

常量对象只能调用常量函数,不能调用非常量函数,但是非常量对象,两者均可调用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值