b********e 发帖数: 215 | 1 1. what is the diff between struct and class? my answer is member variable
in struct is public by default, but class is private, but the interviewer
usually isn't satisfied about this answer.
Is there any other diffs?
2. map用什么实现的?
3. 在构造函数中,在inialize list里初始化成员变量相比在函数体中初始化有什么好处?
4。什么类型的成员变量必须在inialize list中初始化,我回答reference type have to be inialized, what else? |
l*******y 发帖数: 1498 | 2 1. 还有的话就是inheritance一个public一个private by default. 别的都一样了吧?
2. stl map? 是一个balanced BST, look up time是 log(n) |
f*****y 发帖数: 444 | 3 1. member function also default to public.
3. initialization list also faster. One step only: it creates the variable
with the initial value. in function, it has two steps, you create the
variable with default value then need do the assignment.
4. const member variables. |
v***n 发帖数: 5085 | 4
2 RB tree, but u do not have to know the details about RB tree.
【在 l*******y 的大作中提到】 : 1. 还有的话就是inheritance一个public一个private by default. 别的都一样了吧? : 2. stl map? 是一个balanced BST, look up time是 log(n)
|
h**k 发帖数: 3368 | 5 如果需要调用基类的有参数的构造函数,也必须在initialization list里调用。
【在 f*****y 的大作中提到】 : 1. member function also default to public. : 3. initialization list also faster. One step only: it creates the variable : with the initial value. in function, it has two steps, you create the : variable with default value then need do the assignment. : 4. const member variables.
|
c***2 发帖数: 838 | 6 diff between struct and class: inheritance
好处?
have to be inialized, what else?
【在 b********e 的大作中提到】 : 1. what is the diff between struct and class? my answer is member variable : in struct is public by default, but class is private, but the interviewer : usually isn't satisfied about this answer. : Is there any other diffs? : 2. map用什么实现的? : 3. 在构造函数中,在inialize list里初始化成员变量相比在函数体中初始化有什么好处? : 4。什么类型的成员变量必须在inialize list中初始化,我回答reference type have to be inialized, what else?
|