当前位置:网站首页>Day3: Multiple-choice questions required for the interview
Day3: Multiple-choice questions required for the interview
2022-08-06 00:29:00 【Slow Just Fast】
Day3: Required interview questions
Article table of contents

Topic 1
There is a structure like this:
struct A{
long a1;
short a2;
int a3;
int a4;
};
What is the size calculated by sizeof(struct A) under a 64-bit compiler?( ) A
A.24
B.28
C.16
D.18
Analysis:
A. First of all, it is clear that the size of the pointer under 64-bit is 8 bytes, which is the key, a1 occupies 4 bytes, a2 two bytes, since a3 occupies 4 bytes, a2 needs to be filled with 2Byte, for a1, a2, a3, a total of 12 bytes are opened. Since a4 occupies 8 bytes, 4 bytes must be filled after a4 to be an integer multiple of 8, and the final sum is 24 bytes, just rightAlso a multiple of 8, so the final structure size is 24 bytes, answer A
B.Error
C. If the system is 32-bit, the structure size is 16
D. Error
Topic 2
Can a struct in C++ have member functions?( ) B
A. No, struct types do not support member functions
B. May have
C. No, only classes are allowed to have member functions
Analysis:
A.C language structure does not support member functions, but C++ structure supports it. There is no difference between class and struct. The only difference is that by default, the access attribute of class is private and struct is publicp>
B. Correct
C.C++ structs also support member functions
Topic 3
The following statement about the usage of this pointer is correct( )D
A. Ensure that protected members of the base class are accessible in subclasses
B. Ensure that private members of the base class can be accessed in subclasses
C. Ensure that the public members of the base class can be accessed in the subclass
D. Guarantees that each object has its own data members, but shares the code that handles that data
Analysis:
A. The protected members of the base class can be accessed directly in the subclass, regardless of this
B. The private members of the base class cannot be accessed in the subclass, regardless of this
C. The common members of the base class can be accessed directly outside the subclass and the object, regardless of this
D.this pointer represents the current object and can distinguish the own data of each object, so it is correct
Question 4
The error described below is ( ) C
A.this pointer is an implicit parameter of a non-static member function.
B. Every non-static member function has a this pointer.
C.this pointer is stored in the object.
D.this pointer can be null
Analysis:
A. Static member functions do not have this pointer, only non-static member functions have it, and it is a hidden pointer
B. The first parameter of a non-static member function is the hidden this pointer
C.This pointer is in a non-static member function, and the object does not exist, so it is wrong
D. It is not possible to simply assign null to this, but it can be forcedTurn directly to empty, but generally do not do such an operation
边栏推荐
猜你喜欢
随机推荐
Embedded system driver primary [7] - kernel memory management
【mysql】--记一次delete删除语句使用别名的坑
Detailed explanation of pod
Chrome Google Chrome, how to install the appropriate browser driver?
Kubernetes 中的证书管理工具 - cert-manager
【LeetCode】623.在二叉树中增加一行
[2022 强网杯] devnull 复现
在速率分割缓存中工作提前平滑特点是什么?
横向联邦学习-梯度安全聚合(二)
1467. 两个盒子中球的颜色数相同的概率 数学+DFS
Is it safe to choose a mobile phone application for a securities account?
Lateral federal study - gradient security polymerization
接口安全性测试该从哪些方面入手?
华为分析&联运活动,助您提升游戏总体付费
熵力(entropic force)
Pycharm 专业版与社区版的区别
【电商运营】网上商店如何利用好自己的营销数据达成目标?
Insensitivity and Self-Reconciliation
分布式二级缓存组件实战(Redis+Caffeine实现)
使用 shell 脚本: 关闭特定进程









