由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 发几个C++面试题,senior的职位
相关主题
[合集] 贡献几个C/C++编程电话面试题bloomberg 问题: C++ construct 时用 new 没"()"
最新某公司onsite面试题A question about C++. Thanks.
static initialization dependency c++ (转载)让大家了解工业界Java/J2EE面试题的难度
大家推荐几个比较适合做面试题的 c++ 问题吧请教回答这几道面试题(针对文科),谢谢。
公司招人,站内联系谁能解释下这道c++的面试题
有面过knight的吗面试题
C++ Q68: initialization (skillport)请教两个面试题
问一个c++问题关于reference vs. pointerAmazon电面 (05/02/09更新第二次,第三次电面)
相关话题的讨论汇总
话题: what话题: process话题: c++话题: exception话题: debugger
进入JobHunting版参与讨论
1 (共1页)
w********s
发帖数: 1570
1
1,what is abi and api, give some example
2, what happens when exception is thrown?
3, what if exception is not caught anywhere?
4, what must be initialized in the initialization list?
5, what is reference vs. pointer?
6, how do you debug a box which has no debugger installed? i.e. you suspect
a process is hanging, but no debugger, how to tell what goes wrong?
l********t
发帖数: 878
2
1. Know API, never heard ABI
2. All stacks pop
3. Hand all the way to the top, i.e. main(), and then halted by operating
system
4. Question not clear. Nothing, or constant class members.
5. reference is alias, bound forever, can not change.
pointer is more universal, unless you define something like
int * const *
Also there's some difference when you use reference/pointer as parameters
passed into a function.
6. C: printf printf printf printf printf
C++: cout cout cerr cerr
BTW: what do you mean by "a box" here? Linux box? XBOX? SandBox? BlackBox?
s*****r
发帖数: 43070
3
6应该是trigger core dump 所有的thread,用kill send个signal给process,signal
几得查一下

【在 l********t 的大作中提到】
: 1. Know API, never heard ABI
: 2. All stacks pop
: 3. Hand all the way to the top, i.e. main(), and then halted by operating
: system
: 4. Question not clear. Nothing, or constant class members.
: 5. reference is alias, bound forever, can not change.
: pointer is more universal, unless you define something like
: int * const *
: Also there's some difference when you use reference/pointer as parameters
: passed into a function.

w********s
发帖数: 1570
4
According to your answers, you won't pass.
abt 6), it's a linux box, app is already running, no print or log.

【在 l********t 的大作中提到】
: 1. Know API, never heard ABI
: 2. All stacks pop
: 3. Hand all the way to the top, i.e. main(), and then halted by operating
: system
: 4. Question not clear. Nothing, or constant class members.
: 5. reference is alias, bound forever, can not change.
: pointer is more universal, unless you define something like
: int * const *
: Also there's some difference when you use reference/pointer as parameters
: passed into a function.

w********s
发帖数: 1570
5
you can't download files from the box, no gdb there, and the process is
critical, you can't just kill it.

signal

【在 s*****r 的大作中提到】
: 6应该是trigger core dump 所有的thread,用kill send个signal给process,signal
: 几得查一下

l********t
发帖数: 878
6
Good to know. Will study more.
abt 6) How is this question related to C++? How about coding a debugger in C
++?

【在 w********s 的大作中提到】
: According to your answers, you won't pass.
: abt 6), it's a linux box, app is already running, no print or log.

w********s
发帖数: 1570
7
it may be not that related to c++

C

【在 l********t 的大作中提到】
: Good to know. Will study more.
: abt 6) How is this question related to C++? How about coding a debugger in C
: ++?

s*****r
发帖数: 43070
8
不清楚kill干什么的还提问,这是公司问你的问题吧

【在 w********s 的大作中提到】
: you can't download files from the box, no gdb there, and the process is
: critical, you can't just kill it.
:
: signal

l********t
发帖数: 878
9
ah, now I see, it is a linux question. Very curious about the answer from OP.
http://stackoverflow.com/questions/3659065/how-to-check-if-a-pr

【在 w********s 的大作中提到】
: it may be not that related to c++
:
: C

f**d
发帖数: 177
10
你每次都发的什么破题阿, btw, c++11 const data member 可以直接inclass
initialize了, 所以问题4已经不成立了

suspect

【在 w********s 的大作中提到】
: 1,what is abi and api, give some example
: 2, what happens when exception is thrown?
: 3, what if exception is not caught anywhere?
: 4, what must be initialized in the initialization list?
: 5, what is reference vs. pointer?
: 6, how do you debug a box which has no debugger installed? i.e. you suspect
: a process is hanging, but no debugger, how to tell what goes wrong?

相关主题
有面过knight的吗bloomberg 问题: C++ construct 时用 new 没"()"
C++ Q68: initialization (skillport)A question about C++. Thanks.
问一个c++问题关于reference vs. pointer让大家了解工业界Java/J2EE面试题的难度
进入JobHunting版参与讨论
w********s
发帖数: 1570
11
有些process就是不能随便kill啊,比如一个正在交易的程序,你不知道它到底是hang
了,还是正常。production box没有debugger。

【在 s*****r 的大作中提到】
: 不清楚kill干什么的还提问,这是公司问你的问题吧
w********s
发帖数: 1570
12
谁说过只有const是答案?

【在 f**d 的大作中提到】
: 你每次都发的什么破题阿, btw, c++11 const data member 可以直接inclass
: initialize了, 所以问题4已经不成立了
:
: suspect

q****x
发帖数: 7404
13

no context, no idea.
sth like stack unwinding.
forget.
parent class?
this is basic
suspect
for loop dump pstack

【在 w********s 的大作中提到】
: 1,what is abi and api, give some example
: 2, what happens when exception is thrown?
: 3, what if exception is not caught anywhere?
: 4, what must be initialized in the initialization list?
: 5, what is reference vs. pointer?
: 6, how do you debug a box which has no debugger installed? i.e. you suspect
: a process is hanging, but no debugger, how to tell what goes wrong?

s*****r
发帖数: 43070
14
知道是不是行了容易,难的是知道为什么行了

hang

【在 w********s 的大作中提到】
: 有些process就是不能随便kill啊,比如一个正在交易的程序,你不知道它到底是hang
: 了,还是正常。production box没有debugger。

y*******o
发帖数: 6632
15
reference variable

【在 f**d 的大作中提到】
: 你每次都发的什么破题阿, btw, c++11 const data member 可以直接inclass
: initialize了, 所以问题4已经不成立了
:
: suspect

g*******u
发帖数: 3948
16
哪家公司?
我觉得是难啊。。
S**I
发帖数: 15689
17
Based on answers above, no wonder it is hard to find a good C++ programmer
nowadays. :)

suspect

【在 w********s 的大作中提到】
: 1,what is abi and api, give some example
: 2, what happens when exception is thrown?
: 3, what if exception is not caught anywhere?
: 4, what must be initialized in the initialization list?
: 5, what is reference vs. pointer?
: 6, how do you debug a box which has no debugger installed? i.e. you suspect
: a process is hanging, but no debugger, how to tell what goes wrong?

w********s
发帖数: 1570
18
the answeres in that link is terrible as well.

OP.

【在 l********t 的大作中提到】
: ah, now I see, it is a linux question. Very curious about the answer from OP.
: http://stackoverflow.com/questions/3659065/how-to-check-if-a-pr

z****g
发帖数: 5
19
1,what is abi and api, give some example
API=application programing interface. ABI=?
2, what happens when exception is thrown?
In current function, if there is a try-catch, will go to catch part; If
there is try-finally, will go to finally; Otherwise, will go out of the
function and return to previous call.
3, what if exception is not caught anywhere?
The process will end with a certain error and signal.
4, what must be initialized in the initialization list?
For my style, every field must be initialized. For stl, it's not a must
requirement.If it's a c-style list, it depends on the structure.As I always
init everything, there is no problem.
5, what is reference vs. pointer?
Almost the same. Both represents the address of variable. Pointer can be
casted to any other types of pointers.
6, how do you debug a box which has no debugger installed? i.e. you suspect
a process is hanging, but no debugger, how to tell what goes wrong?
The key point is collecting the threads's stack info. Remote debugging and
core dump analysis are both okay. The exact steps might be as below:
First, we should talk to the box using tools such like ssh, telnet, serial
port usb and etc.
Second, after the connection is established, we should indentify whether it'
s a dead lock or endless loop by checking the CPU usage. And then, we should
identify whether the hang is in user-space or kernel-space. If it's in
kernel space, the process can not be killed, so we can try to kill the
process. But before kill it, we must ensure the killing would not impact the
business and most importantly, we must get the core file(on linux, we can
use gcore; on windows, we can use tool like windbg...). After user-mode core
file are collected, we can try to kill the process. If it's cannot be
killed, the problem must be in kernel. At this stage, we need remote
debugging or collect the kernel core dump: on linux, we can use 'echo *'(I
forget the exact command) to mannual trigger; on windows, we can use a
customized kernel module to trigger it.
Third, if we have a core file(no matter where it is), list all the threads'
stack.
1) for endless loop, check the running time and start time and stack infor.
2) for dead lock, check every thread where it is stuck.
w********s
发帖数: 1570
20
most of your answers are bad.
for example, C++ does not have finally.
you still don't know what exception is not caught.
and there's no remote debugging as it's a production box, everything is
restricted, you cannot download dump file even you collect.

【在 z****g 的大作中提到】
: 1,what is abi and api, give some example
: API=application programing interface. ABI=?
: 2, what happens when exception is thrown?
: In current function, if there is a try-catch, will go to catch part; If
: there is try-finally, will go to finally; Otherwise, will go out of the
: function and return to previous call.
: 3, what if exception is not caught anywhere?
: The process will end with a certain error and signal.
: 4, what must be initialized in the initialization list?
: For my style, every field must be initialized. For stl, it's not a must

相关主题
请教回答这几道面试题(针对文科),谢谢。请教两个面试题
谁能解释下这道c++的面试题Amazon电面 (05/02/09更新第二次,第三次电面)
面试题如何准备bloomberg online test
进入JobHunting版参与讨论
z****g
发帖数: 5
21
Actually, if you have developped windows driver, there is indeed try-finally
. C++ can be used to develop windows filesystem driver and there is try-
finally and I used it.It depends on the system and compiler.
For exception, I cannot describe it as same as book. However,I think if
there is a problem or a snippet of code. I'm sure I can describe it clearly.
For the box, my company is focus on appliance. I have to say it's a bad box
if the box has no way to remote debugging. Debugable is a base requirement
for any software.I will netver let that happen in my project. I have
debugged over 4000 dead locks both in user-space and kernel-space, so what I
said is the best practice.If you have better methods, I'm glad to learn it.

【在 w********s 的大作中提到】
: most of your answers are bad.
: for example, C++ does not have finally.
: you still don't know what exception is not caught.
: and there's no remote debugging as it's a production box, everything is
: restricted, you cannot download dump file even you collect.

b******z
发帖数: 410
22
Your answer for exception is wrong, stack unwonding is the answer

finally
clearly.
★ 发自iPhone App: ChineseWeb 8.6

【在 z****g 的大作中提到】
: Actually, if you have developped windows driver, there is indeed try-finally
: . C++ can be used to develop windows filesystem driver and there is try-
: finally and I used it.It depends on the system and compiler.
: For exception, I cannot describe it as same as book. However,I think if
: there is a problem or a snippet of code. I'm sure I can describe it clearly.
: For the box, my company is focus on appliance. I have to say it's a bad box
: if the box has no way to remote debugging. Debugable is a base requirement
: for any software.I will netver let that happen in my project. I have
: debugged over 4000 dead locks both in user-space and kernel-space, so what I
: said is the best practice.If you have better methods, I'm glad to learn it.

s**x
发帖数: 7506
23
赶紧公布正确答案吧,尤其是最后一道题。
J*****s
发帖数: 110
24
ABI是 application binary interface, 涉及到编译器对语言的实现, 典型的如vtable
的实现, 函数参数的传递.....等等二进制兼容的问题.

【在 l********t 的大作中提到】
: 1. Know API, never heard ABI
: 2. All stacks pop
: 3. Hand all the way to the top, i.e. main(), and then halted by operating
: system
: 4. Question not clear. Nothing, or constant class members.
: 5. reference is alias, bound forever, can not change.
: pointer is more universal, unless you define something like
: int * const *
: Also there's some difference when you use reference/pointer as parameters
: passed into a function.

z******g
发帖数: 271
25
Are you expecting constructor of super class with argument for Q4?
z******g
发帖数: 271
26
I think the most significant difference between the usage of pointer and
reference is support on arithmetic operation.
f****4
发帖数: 1359
27
6: > pstack `ps --no-headers -o pid -C yourbin` >> log

suspect

【在 w********s 的大作中提到】
: 1,what is abi and api, give some example
: 2, what happens when exception is thrown?
: 3, what if exception is not caught anywhere?
: 4, what must be initialized in the initialization list?
: 5, what is reference vs. pointer?
: 6, how do you debug a box which has no debugger installed? i.e. you suspect
: a process is hanging, but no debugger, how to tell what goes wrong?

b****f
发帖数: 138
28
Mark
s**x
发帖数: 7506
29

reference has to refer something, there is no null reference, while a
pointer can be null.
Reference is implemented with pointers.

【在 z******g 的大作中提到】
: I think the most significant difference between the usage of pointer and
: reference is support on arithmetic operation.

t****t
发帖数: 6806
30

abi=application binary interface, 最主要的是决定函数怎么调用, 还有name
mangling, exception的处理
api还用说么.
stack unwind until caught, or until another exception (terminate())
unexpected()
EDIT:搞混了, 是terminate(). unexpected发生在扔出说明里没有的异常时.
const, reference, parent class w/o default ctor
reference can not be reseated, can not have nullptr value
suspect
这个太泛泛了, 必须得有点背景才行吧. 比如说看/proc/pid里的东西, 但是看什么就
很难说了.

【在 w********s 的大作中提到】
: 1,what is abi and api, give some example
: 2, what happens when exception is thrown?
: 3, what if exception is not caught anywhere?
: 4, what must be initialized in the initialization list?
: 5, what is reference vs. pointer?
: 6, how do you debug a box which has no debugger installed? i.e. you suspect
: a process is hanging, but no debugger, how to tell what goes wrong?

相关主题
一个电面最新某公司onsite面试题
written test from Interactive Brokersstatic initialization dependency c++ (转载)
[合集] 贡献几个C/C++编程电话面试题大家推荐几个比较适合做面试题的 c++ 问题吧
进入JobHunting版参与讨论
t****t
发帖数: 6806
31
finally是VC自己加的, 不能算C++.

finally
clearly.
box
I
it.

【在 z****g 的大作中提到】
: Actually, if you have developped windows driver, there is indeed try-finally
: . C++ can be used to develop windows filesystem driver and there is try-
: finally and I used it.It depends on the system and compiler.
: For exception, I cannot describe it as same as book. However,I think if
: there is a problem or a snippet of code. I'm sure I can describe it clearly.
: For the box, my company is focus on appliance. I have to say it's a bad box
: if the box has no way to remote debugging. Debugable is a base requirement
: for any software.I will netver let that happen in my project. I have
: debugged over 4000 dead locks both in user-space and kernel-space, so what I
: said is the best practice.If you have better methods, I'm glad to learn it.

t****t
发帖数: 6806
32
afaik if you use signal to force core dump, it will also stop the process.
so his concern is legitmate.

【在 s*****r 的大作中提到】
: 不清楚kill干什么的还提问,这是公司问你的问题吧
w********s
发帖数: 1570
33
yes, but there are more items.

【在 z******g 的大作中提到】
: Are you expecting constructor of super class with argument for Q4?
w********s
发帖数: 1570
34
of coz you can debug in your qa env, but what if it's in production env? how
do you resove issues there?

finally
clearly.
box
I
it.

【在 z****g 的大作中提到】
: Actually, if you have developped windows driver, there is indeed try-finally
: . C++ can be used to develop windows filesystem driver and there is try-
: finally and I used it.It depends on the system and compiler.
: For exception, I cannot describe it as same as book. However,I think if
: there is a problem or a snippet of code. I'm sure I can describe it clearly.
: For the box, my company is focus on appliance. I have to say it's a bad box
: if the box has no way to remote debugging. Debugable is a base requirement
: for any software.I will netver let that happen in my project. I have
: debugged over 4000 dead locks both in user-space and kernel-space, so what I
: said is the best practice.If you have better methods, I'm glad to learn it.

w********s
发帖数: 1570
35
4, you missed 'For initialization of member objects which do not have
default constructor'

【在 t****t 的大作中提到】
: afaik if you use signal to force core dump, it will also stop the process.
: so his concern is legitmate.

t****t
发帖数: 6806
36
哦, 对. 不过说实话我觉得考背书意思不大.

【在 w********s 的大作中提到】
: 4, you missed 'For initialization of member objects which do not have
: default constructor'

m*****o
发帖数: 70
37
1) arm-none-eabi-gcc ? compiler related.
6) JTAG? hardware debugger. actually JTAG with GDB
m********x
发帖数: 103
38
mark
c********r
发帖数: 107
39
mark
k**********g
发帖数: 989
40
I think I didn't do well on 1-5. When I'm in front of a C++ code base I can
remember much stuff. When I'm browsing MITBBS I can't recall much off hand.
6. Packet sniffer?
If the host doesn't communicate with outside, it is effectively a
Schrodinger's box. Just power-cycle it.
If it communicates with outside, then try to analyze how it communicates
with outside, and then deduce if the behavior is normal or bad. If it is bad
, and there's nothing you can do to fix it, then collect enough packets and
power-cycle it.
相关主题
大家推荐几个比较适合做面试题的 c++ 问题吧C++ Q68: initialization (skillport)
公司招人,站内联系问一个c++问题关于reference vs. pointer
有面过knight的吗bloomberg 问题: C++ construct 时用 new 没"()"
进入JobHunting版参与讨论
w*****d
发帖数: 105
41
1,what is abi and api, give some example
api: usually means interfaces of a library or class.
abi: this is means the binary conversion rules for different compilers or
platforms, such as arguments order in stack for a function call.
2, what happens when exception is thrown?
in C++, the following operations are carried out:
1)unwind the current stack, call any dtor for local vars if necessary, until
there is a catch block that can handle the exception obj;
2)if there is no such catch block in the end(unwind to the bottom of the
stack), abort() the process.
3, what if exception is not caught anywhere?
abort() the process.
4, what must be initialized in the initialization list?
any non-static member var or base class, that have no default ctor, that is
can be called without arguments.
const member var is just one case of those.
5, what is reference vs. pointer?
pointer means an address, with a rep. of type. pointers can be null, or
uninitialized with any value.
ref is an alias for a var, so it must be initialized, and there is no null
ref.
but under the surface, ref is implemented via pointer, so they are identical
to the compiler.
6, how do you debug a box which has no debugger installed? i.e. you suspect
a process is hanging, but no debugger, how to tell what goes wrong?
it depends on many things, such as OS, process behavior, or other processes.
in linux, i usually use 'top' first to see the TIME+ of the target process,
and check any strange if the process should be busy/idle. if the process
has network traffic or io operations, 'sar'/'vmstat'/'iostat' can be used to
check any thing strange. and if there is a counter for requests handled by
the process, that's a straight way to tell whether the process is hanging.
1 (共1页)
进入JobHunting版参与讨论
相关主题
Amazon电面 (05/02/09更新第二次,第三次电面)公司招人,站内联系
如何准备bloomberg online test有面过knight的吗
一个电面C++ Q68: initialization (skillport)
written test from Interactive Brokers问一个c++问题关于reference vs. pointer
[合集] 贡献几个C/C++编程电话面试题bloomberg 问题: C++ construct 时用 new 没"()"
最新某公司onsite面试题A question about C++. Thanks.
static initialization dependency c++ (转载)让大家了解工业界Java/J2EE面试题的难度
大家推荐几个比较适合做面试题的 c++ 问题吧请教回答这几道面试题(针对文科),谢谢。
相关话题的讨论汇总
话题: what话题: process话题: c++话题: exception话题: debugger