当前位置:网站首页>Day6: Multiple-choice questions required for the interview
Day6: Multiple-choice questions required for the interview
2022-08-06 00:29:00 【Slow Just Fast】
Day6:Interview questions

题目一
已知表达式++a中的"++"是作为成员函数重载的运算符,则与++a等效的运算符函数调用形式为( ) A
A.a.operator++()
B.a.operator++(0)
C.a.operator++(int)
D.operator++(a,0)
解析:
A.正确
B.operator++()传递了整形参数,Hence the post++,错误
C.Call the function passing the type,导致语法错误
D.参数过多,语法错误
题目二
在重载一个运算符为成员函数时,其参数表中没有任何参数,这说明该运算符是 ( ) C
A.无操作数的运算符
B.二元运算符
C.前缀一元运算符
D.后缀一元运算符
解析:
A.重载为成员函数时,其函数的参数个数与真实的函数参数个数会减少1个,减少的则 通过this指针进行传递,So no reference then there is one parameter,故错误
B.无参成员函数相当于有一个参数的全局函数,不能是二元运算符
C.正确
D.When distinguishing between prefix and suffix,Postfix operations need to add oneint参数
题目三
Which operator cannot be overloaded ( ) C
A.*
B.()
C… (点)
D.[]
E.->
解析:
A.可以,For example, overloading object values,Typically there are smart pointers learned later
B.可以,For example, functors learned later are through overloading()实现的
C.不能,Operators that cannot be overloaded are only5个, 点号. 三目运算?: Scope access question mark:: 运算符sizeof 以及.*
D.可以,For example overloading the pointer to the object,Typically there are smart pointers learned later
题目四
若要对dataThe overloaded addition operator member function is declared in the class,下列选项中正确的是( ) A
A.Data operator+(Data);
B.Data operator(Data);
C.operator+(Data,Data);
D.Data+(Data);
解析:
A.正确
B.语法错误,缺少运算符+
C.Member function has too many arguments
D.There is no operator overloading keywordoperator
题目五
假设 AA 是一个类, AA* abc () const 是该类的一个成员函数的原型.若该函数返回 this 值,当用 x.abc ()调用该成员函数后, x 的值是( )D
A.可能被改变
B.已经被改变
C. 受到函数调用的影响
D.不变
解析:
A.This member function is defined asconst常方法,代表在函数内部不能修改任何当前对象的数据成员,因此x不可能改变
B.错误,不能被改变
C.x的值在函数内部不受任何影响
D.正确
题目六
下列关于赋值运算符“=”重载的叙述中,正确的是( ) A
A.赋值运算符只能作为类的成员函数重载
B.默认的赋值运算符实现了“深层复制”功能
C.重载的赋值运算符函数有两个本类对象作为形参
D.如果己经定义了复制拷贝构造函数,就不能重载赋值运算符
解析:
A. 赋值运算符在类中不显式实现时,编译器会生成一份默认的,此时用户在类外再将赋值运算符重载为全局的,就和编译器生成的默认赋值运算符冲突了,故赋值运算符只能重载成成员函数
B.The default assignment operator is member-by-member,It is a shallow assignment
C.参数只有一个,另一个通过this指针传递
D.两个函数的调用场景不同,相互没有影响
边栏推荐
猜你喜欢

正在安装最新版本的origin太慢了

如何对齐微信小程序胶囊按钮?

17、学习MySQL 事务

Yiwei Lithium's first system product equipped with 46 series large cylindrical batteries successfully rolled off the production line

『牛客|每日一题』N皇后问题

解决HBuilderX无法登录的问题

Simple use of Day15 jenkins

程序员的浪漫:七夕准备好表白了吗

Graphical LeetCode - 623. Add a row to a binary tree (difficulty: medium)

Chrome Google Chrome, how to install the appropriate browser driver?
随机推荐
2022中国大健康展,山东大健康展,济南健康展,健康产业展
正则表达式完整入门教程,含在线练习
为啥强烈禁止使用Calendar?
Vim编辑器常用命令汇总
openstack架构中给虚拟机提供存储资源的组件是什么
17、学习MySQL 事务
SRE ops declassified - service quality target: the SLI, SLO, SLA
【论文阅读】Virtual Adversarial Training: a Regularization Method for SL and SSL
OA项目线程内共享上下文实例(二)
oracle学习笔记识别低效sql(十九)
代理缓存的问题是什么呢?
在速率分割缓存中缓存思路是什么?
【LeetCode】611.有效三角形的个数
AVL树的学习
[2022 强网杯] house_of_cat 战战兢兢的复现
阿里资深技术专家带你聊一聊服务端的接口测试
Kubernetes implements grayscale and blue-green releases
架构基本概念和架构本质
Taught you how to locate online MySQL lock timeout problem, BaoJiao package
湖仓一体电商项目(六):大屏可视化工具腾讯云图