由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Quant版 - C++ and threading interview questions
相关主题
也问一个题--C++R studio 进入debug状态后, 很慢 ? (转载)
面试题 Interest Rate Product Group of GS面试题
请给些C++学习建议问一个C的简单问题
求纽约市excel & VS C++高手周末辅导编程how to debug multi-thread program?
问个C++的土问题,见笑了。C++ and threading interview questions
[合集] Hedge fund面试要做test, 会怎么样?多少个thread 就算不正常?
用Visual Studio 2008 debug DLL.面试问题一问 (转载)
20kC++ Interview Question
相关话题的讨论汇总
话题: vector话题: c++话题: size话题: compiling话题: threading
进入Quant版参与讨论
1 (共1页)
d*********1
发帖数: 25
1
a few interview questions:
1) is the c++ template parameters decided by the compiling time or running
time?
2) how do you know that a C++ template parameter are decided at the
compiling or running time?
3) what is the initial size of a vector?
4) Can the vector reaches maximum size be changed and how to change it?
5) what kind of tools are you using for debuging multiple threading?
6) how would you know a process is in deadlock? eg in debug mode.
My answers:
1) compiling time?
2) donot know....
m********0
发帖数: 2717
2
1) compiling
2) designed to be static polymorphism?
3) depends on how you initialize the vector, for default constructor,
vector = vector = vector = vector = 12 on 32
os. vector = 20
4) yes, use vector::reserve(size_type n)
6) deadlock detection is hard. 4 conditions:
Mutual exclusion
Hold and wait
No preemption
Circular wait
don't know how to check it in debug mode

【在 d*********1 的大作中提到】
: a few interview questions:
: 1) is the c++ template parameters decided by the compiling time or running
: time?
: 2) how do you know that a C++ template parameter are decided at the
: compiling or running time?
: 3) what is the initial size of a vector?
: 4) Can the vector reaches maximum size be changed and how to change it?
: 5) what kind of tools are you using for debuging multiple threading?
: 6) how would you know a process is in deadlock? eg in debug mode.
: My answers:

p****x
发帖数: 707
3
you sure about the initial size? in:
http://www.cplusplus.com/reference/stl/vector/vector/
explicit vector ( const Allocator& = Allocator() );
Default constructor: constructs an empty vector, with no content and a
size of zero.
with a test, after initialization,the size and capacity both are 0, and max_
size is -1. Why -1?

【在 m********0 的大作中提到】
: 1) compiling
: 2) designed to be static polymorphism?
: 3) depends on how you initialize the vector, for default constructor,
: vector = vector = vector = vector = 12 on 32
: os. vector = 20
: 4) yes, use vector::reserve(size_type n)
: 6) deadlock detection is hard. 4 conditions:
: Mutual exclusion
: Hold and wait
: No preemption

m********0
发帖数: 2717
4
I am sure about my result with gnu cpp stl
with g++ compiler.
Tested.
sizeof could not be zero, sizeof(empty clas) = 1;
and for sizeof(vector) I guess the reason is
it only counts three pointers
_M_start, _M_finish, _M_end_of_storage

max_

【在 p****x 的大作中提到】
: you sure about the initial size? in:
: http://www.cplusplus.com/reference/stl/vector/vector/
: explicit vector ( const Allocator& = Allocator() );
: Default constructor: constructs an empty vector, with no content and a
: size of zero.
: with a test, after initialization,the size and capacity both are 0, and max_
: size is -1. Why -1?

m********0
发帖数: 2717
5
for vector
it has _M_offset for _M_begin and _M_finish
so sizeof (vector) is 20.
p****x
发帖数: 707
6
ok. sizeof of a variable, or initial size of a container?
I guess the interview question is about the later.

【在 m********0 的大作中提到】
: I am sure about my result with gnu cpp stl
: with g++ compiler.
: Tested.
: sizeof could not be zero, sizeof(empty clas) = 1;
: and for sizeof(vector) I guess the reason is
: it only counts three pointers
: _M_start, _M_finish, _M_end_of_storage
:
: max_

m********0
发帖数: 2717
7
yes, without definition of "size"
it's confusing.
and sometimes they ask about sizeof a class/variable.
which is the former.
it's too trivial to ask intial number of data in a default vector.

【在 p****x 的大作中提到】
: ok. sizeof of a variable, or initial size of a container?
: I guess the interview question is about the later.

w*******r
发帖数: 18
8
嗯,这三个sizeof只是那三个iterator的大小吧
觉得就算用过c++编过很多程,回答好多面试的这些细节问题,还是挺头疼的啊

【在 m********0 的大作中提到】
: for vector
: it has _M_offset for _M_begin and _M_finish
: so sizeof (vector) is 20.

1 (共1页)
进入Quant版参与讨论
相关主题
C++ Interview Question问个C++的土问题,见笑了。
在子函数内开内存,返回主函数指针然后释放空间是不是很糟糕的(转载)[合集] Hedge fund面试要做test, 会怎么样?
c interview question用Visual Studio 2008 debug DLL.
google 电面 software engr in test20k
也问一个题--C++R studio 进入debug状态后, 很慢 ? (转载)
面试题 Interest Rate Product Group of GS面试题
请给些C++学习建议问一个C的简单问题
求纽约市excel & VS C++高手周末辅导编程how to debug multi-thread program?
相关话题的讨论汇总
话题: vector话题: c++话题: size话题: compiling话题: threading