S******n 发帖数: 132 | 1 第一个电话面试,答得不好
C++的几道题
1. why mutable, when should we use mutable?
我就按定义说了,想在const成员函数里面改变member variable,就需要mutable
然后他说你既然把函数定义成了const,就不应该去改变member variable,然后问我什
么情况下需要mutable,这样说来我就真不知道了,谁来解答一下
2. order of construction for member variables.
3. extern 用法: extern int c = 0; 合法吗?什么情况下需要用extern,有什么优
劣性
4. static用法
5. volatile用法,什么情况下使用,举例
这个我也答得不好,因为没用过,就记得概念,实际应用就不知道了
6. Fibonacci函数,要compile-time得到结果
template metaprogramming这个东西金融公司里面用得多吗?
template平时工作中用的多吗?如果真的挺重要,我还得努力补习一下
7. deque vs vector
好像就这些,想起来再补上 |
s******n 发帖数: 3946 | 2 学习了,mutable确实很搞,这个帖子说的还算清楚吗?
http://www.highprogrammer.com/alan/rants/mutable.html
就是说逻辑上函数是const的,但是实现上必须修改内变量。
啥金融公司C++扣得那么细 |
S*******w 发帖数: 24236 | 3 他们就是搞c++ 其它他们不在乎
【在 s******n 的大作中提到】 : 学习了,mutable确实很搞,这个帖子说的还算清楚吗? : http://www.highprogrammer.com/alan/rants/mutable.html : 就是说逻辑上函数是const的,但是实现上必须修改内变量。 : 啥金融公司C++扣得那么细
|
l*****a 发帖数: 14598 | 4 对于const variable 也可以用mutable
【在 S******n 的大作中提到】 : 第一个电话面试,答得不好 : C++的几道题 : 1. why mutable, when should we use mutable? : 我就按定义说了,想在const成员函数里面改变member variable,就需要mutable : 然后他说你既然把函数定义成了const,就不应该去改变member variable,然后问我什 : 么情况下需要mutable,这样说来我就真不知道了,谁来解答一下 : 2. order of construction for member variables. : 3. extern 用法: extern int c = 0; 合法吗?什么情况下需要用extern,有什么优 : 劣性 : 4. static用法
|
q****x 发帖数: 7404 | 5 一听就是金融公司的变态题。
【在 S******n 的大作中提到】 : 第一个电话面试,答得不好 : C++的几道题 : 1. why mutable, when should we use mutable? : 我就按定义说了,想在const成员函数里面改变member variable,就需要mutable : 然后他说你既然把函数定义成了const,就不应该去改变member variable,然后问我什 : 么情况下需要mutable,这样说来我就真不知道了,谁来解答一下 : 2. order of construction for member variables. : 3. extern 用法: extern int c = 0; 合法吗?什么情况下需要用extern,有什么优 : 劣性 : 4. static用法
|
M****g 发帖数: 162 | 6 LZ这是什么类型的职位阿?竟然问template metaprogramming... |
q****x 发帖数: 7404 | 7 炫技而已。
【在 M****g 的大作中提到】 : LZ这是什么类型的职位阿?竟然问template metaprogramming...
|
S******n 发帖数: 132 | 8 C++ developer
【在 M****g 的大作中提到】 : LZ这是什么类型的职位阿?竟然问template metaprogramming...
|
S******n 发帖数: 132 | 9 什么意思?能举个例子吗?
【在 l*****a 的大作中提到】 : 对于const variable 也可以用mutable
|
P*******1 发帖数: 1022 | 10 问那些technical 的问题。这种interview好难啊。 |
|
|
T********3 发帖数: 72 | 11 要compile time得到结果???
【在 S******n 的大作中提到】 : 第一个电话面试,答得不好 : C++的几道题 : 1. why mutable, when should we use mutable? : 我就按定义说了,想在const成员函数里面改变member variable,就需要mutable : 然后他说你既然把函数定义成了const,就不应该去改变member variable,然后问我什 : 么情况下需要mutable,这样说来我就真不知道了,谁来解答一下 : 2. order of construction for member variables. : 3. extern 用法: extern int c = 0; 合法吗?什么情况下需要用extern,有什么优 : 劣性 : 4. static用法
|
r****t 发帖数: 10904 | 12 这个不算细了,primer 里面都有了,细的是 primer 里面没有的。
【在 s******n 的大作中提到】 : 学习了,mutable确实很搞,这个帖子说的还算清楚吗? : http://www.highprogrammer.com/alan/rants/mutable.html : 就是说逻辑上函数是const的,但是实现上必须修改内变量。 : 啥金融公司C++扣得那么细
|
r****t 发帖数: 10904 | 13 这还叫难?
【在 P*******1 的大作中提到】 : 问那些technical 的问题。这种interview好难啊。
|
r****t 发帖数: 10904 | 14 这还叫难?
【在 P*******1 的大作中提到】 : 问那些technical 的问题。这种interview好难啊。
|
b*f 发帖数: 3154 | 15 mutable is to tell the compiler to be careful when optimizing this code as
the value of this variable can be changed outside of the current context.
For example,
int x = 0;
while(x == 0)
{
...
}
compiler will optimize away the comparison because within the context there
is no other way can change the value of x. But if you put mutable, compiler
will not do such optimization. |
e***s 发帖数: 799 | 16 同问, compile-time得到结果是什么意思?
【在 T********3 的大作中提到】 : 要compile time得到结果???
|
q****x 发帖数: 7404 | 17 变。
【在 r****t 的大作中提到】 : 这还叫难?
|
l*****a 发帖数: 14598 | 18 class A
{
public:
mutable int i;
}
const A a;
a.i=1;
a.1=2;
【在 S******n 的大作中提到】 : 什么意思?能举个例子吗?
|
n*******s 发帖数: 482 | 19 isn't what you described for volatile ?
as
context.
there
compiler
【在 b*f 的大作中提到】 : mutable is to tell the compiler to be careful when optimizing this code as : the value of this variable can be changed outside of the current context. : For example, : int x = 0; : while(x == 0) : { : ... : } : compiler will optimize away the comparison because within the context there : is no other way can change the value of x. But if you put mutable, compiler
|
b*f 发帖数: 3154 | 20 hah... my mistake, my mistake... how embarrassing...
【在 n*******s 的大作中提到】 : isn't what you described for volatile ? : : as : context. : there : compiler
|