Redian新闻
>
请问Hilton的Executive Lounge可以带家属去吗?
avatar
请问Hilton的Executive Lounge可以带家属去吗?# Money - 海外理财
L*e
1
骑驴找驴,砸了面试,潜心修行,明春再战。
//1. what is the output of the following program?
class A{
public:
struct HEADER{
int a_;
double b_;
unsigned int c_;
unsigned char d_;
static int SIZE = 100;
}header;
private:
double k;
};
int main()
{
A a;
cout << "sizeof A: " << sizeof(a) << endl;
cout << "sizeof structure: " << sizeof(a.HEADER) << endl;
}
//2. What is the output of the following program?
void print(int a, int b)
{
cout<
avatar
i*w
2
rt, thanks
avatar
p*7
3
什么公司啊? onsite考这些?
avatar
i*y
4
你这是什么问题啊?你定了executive level的房间,就可以access lounge。和你在同
一个reservation的guest也是可以access的。什么叫带家属?

【在 i******w 的大作中提到】
: rt, thanks
avatar
P*b
5
我来试试
1. 20
2. 20 1
3. core dump. methodC可以出来
4. 语法错
5. 语法错
6. 乱码
7. A::foo()
8. 100
9. 0 10 40 0
10. our o

【在 L*******e 的大作中提到】
: 骑驴找驴,砸了面试,潜心修行,明春再战。
: //1. what is the output of the following program?
: class A{
: public:
: struct HEADER{
: int a_;
: double b_;
: unsigned int c_;
: unsigned char d_;
: static int SIZE = 100;

avatar
k*n
6
同问

【在 p********7 的大作中提到】
: 什么公司啊? onsite考这些?
avatar
j*l
7
难道是Bloomberg?
avatar
p*7
8
第二题是 30 1,是不是因为传入函数的参数顺序是从右到左
第三题 是对的,不知道A *p = 0;其实是给p一个NULL指针,还是没实例化,但是他可以调用
函数,因为这些函数不占用内存。
第八题和第二题类似,应该是个随机数,因为初始化列表的顺序是从右向左,所以你调用
getnumber先,赋值在后
第九题也不对,是随机数,10,40,随机数。只有全局变量才初始化为0

【在 P*******b 的大作中提到】
: 我来试试
: 1. 20
: 2. 20 1
: 3. core dump. methodC可以出来
: 4. 语法错
: 5. 语法错
: 6. 乱码
: 7. A::foo()
: 8. 100
: 9. 0 10 40 0

avatar
t*j
9
第一题怎么会是20?我算出来是21,static的那个数字大小没算上去。
哪位高人讲解下?还有Header的size应该是多少?

【在 L*******e 的大作中提到】
: 骑驴找驴,砸了面试,潜心修行,明春再战。
: //1. what is the output of the following program?
: class A{
: public:
: struct HEADER{
: int a_;
: double b_;
: unsigned int c_;
: unsigned char d_;
: static int SIZE = 100;

avatar
p*7
10
我不是高人,但是我知道static变量是在这里占用内存的,是在静态变量区。
如果是个空的struct,会占用1byte,不是因为有static

【在 t*****j 的大作中提到】
: 第一题怎么会是20?我算出来是21,static的那个数字大小没算上去。
: 哪位高人讲解下?还有Header的size应该是多少?

avatar
h*k
11
第一题不对,class size是32,struct size 是24。第一个int要和第二个double对齐
,所以是8个字节;char要补到4个字节;static变量不占空间。

【在 P*******b 的大作中提到】
: 我来试试
: 1. 20
: 2. 20 1
: 3. core dump. methodC可以出来
: 4. 语法错
: 5. 语法错
: 6. 乱码
: 7. A::foo()
: 8. 100
: 9. 0 10 40 0

avatar
t*j
12
32 24这个答案是对的,我在计算机上试过了。
为什么要对齐,我不太明白。高人讲讲?
第二题确实是 30 1,计算机试过了。

【在 h**k 的大作中提到】
: 第一题不对,class size是32,struct size 是24。第一个int要和第二个double对齐
: ,所以是8个字节;char要补到4个字节;static变量不占空间。

avatar
P*b
13
你们用的啥编译器?

【在 t*****j 的大作中提到】
: 32 24这个答案是对的,我在计算机上试过了。
: 为什么要对齐,我不太明白。高人讲讲?
: 第二题确实是 30 1,计算机试过了。

avatar
p*7
14
我用gcc为啥是28,20.。。。

【在 P*******b 的大作中提到】
: 你们用的啥编译器?
avatar
a*n
15
还算简单, 两个地方需要注意:
第二题 什么答案都是错的,google "sequence point"
第六题 memset(p, 'A', 10);memset 中的第二个参数为unsigned char
avatar
P*b
16
我估计你们的8字节对齐。我的是4字节对齐
感觉4字节对齐更多吧。
另外这道题有错误。static赋值不对吧?

【在 p********7 的大作中提到】
: 我用gcc为啥是28,20.。。。
avatar
w*3
17
谁能讲讲第二题wsm 是30,1?
avatar
P*b
18
这里没有sequence point的概念吧。

【在 a****n 的大作中提到】
: 还算简单, 两个地方需要注意:
: 第二题 什么答案都是错的,google "sequence point"
: 第六题 memset(p, 'A', 10);memset 中的第二个参数为unsigned char

avatar
L*e
19
I tried to write down all I can remember after the interview, probably not
accurate. Correct any grammar errors if you find.

【在 P*******b 的大作中提到】
: 我估计你们的8字节对齐。我的是4字节对齐
: 感觉4字节对齐更多吧。
: 另外这道题有错误。static赋值不对吧?

avatar
k*n
20
第八题初始化的顺序应该是member定义的顺序吧

可以调用
调用

【在 p********7 的大作中提到】
: 第二题是 30 1,是不是因为传入函数的参数顺序是从右到左
: 第三题 是对的,不知道A *p = 0;其实是给p一个NULL指针,还是没实例化,但是他可以调用
: 函数,因为这些函数不占用内存。
: 第八题和第二题类似,应该是个随机数,因为初始化列表的顺序是从右向左,所以你调用
: getnumber先,赋值在后
: 第九题也不对,是随机数,10,40,随机数。只有全局变量才初始化为0

avatar
p*7
21
you are right

【在 k********n 的大作中提到】
: 第八题初始化的顺序应该是member定义的顺序吧
:
: 可以调用
: 调用

avatar
L*e
22
GS

【在 j**l 的大作中提到】
: 难道是Bloomberg?
avatar
h*k
23
我用的机器也是32bit操作系统。你可以用sizeof(void *)看看,如果是4就是32位系统。
C++不允许这样给非const的静态成员初始化,我猜楼主是漏了const。

【在 P*******b 的大作中提到】
: 我估计你们的8字节对齐。我的是4字节对齐
: 感觉4字节对齐更多吧。
: 另外这道题有错误。static赋值不对吧?

avatar
h*k
24
http://en.wikipedia.org/wiki/Data_structure_alignment

【在 t*****j 的大作中提到】
: 32 24这个答案是对的,我在计算机上试过了。
: 为什么要对齐,我不太明白。高人讲讲?
: 第二题确实是 30 1,计算机试过了。

avatar
s*n
25
考的struct要加padding吧。这个和机器位数有关。

【在 t*****j 的大作中提到】
: 第一题怎么会是20?我算出来是21,static的那个数字大小没算上去。
: 哪位高人讲解下?还有Header的size应该是多少?

avatar
s*n
26
c 压栈方式从右到左。pascal从左到右。

【在 w*****3 的大作中提到】
: 谁能讲讲第二题wsm 是30,1?
avatar
s*n
27
题目挺好。不过有经验的加上看看effective C++应该搞定不少。

【在 L*******e 的大作中提到】
: 骑驴找驴,砸了面试,潜心修行,明春再战。
: //1. what is the output of the following program?
: class A{
: public:
: struct HEADER{
: int a_;
: double b_;
: unsigned int c_;
: unsigned char d_;
: static int SIZE = 100;

avatar
x*k
28
第一题应该是 static const int SIZE = 100;(Effective C++, 3rd edition
, item 2)
具体结果depends compiler和编译选项。32 24是可能值之一。g++下是28 20,static
const int size不占sizeof的空间,按照4byte alignment。
可以用 -fdump-class-hierarchy dump出class的layout文件。
第二题在C++ compiler下应该是不确定。但我见过的编译器都是从右到左进行参数计算
,但g++会给warning “test.cpp:28: warning: operation on ‘i’ may be
undefined”,
test.cpp line 28 is like "fun(i++, i++)"
Effective C++, 3rd edition, item 17, P76
C++ compilers are granted considerable latitude in determining the ord
avatar
C*0
29
不是很懂,不过还好有驴,所以还是有机会的,加油!
avatar
c*r
30
第6题应该是k is undefined的吧。

【在 P*******b 的大作中提到】
: 我来试试
: 1. 20
: 2. 20 1
: 3. core dump. methodC可以出来
: 4. 语法错
: 5. 语法错
: 6. 乱码
: 7. A::foo()
: 8. 100
: 9. 0 10 40 0

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。