由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 问个面试问题,请教
相关主题
问个题。A C++ compiler related interview question
[合集] C++ interview question help一道面试怪题C++. (转载)
急问:compile and build dependencyStrange problem with CGI (转载)
third party c/c++ code and compile it on win 7Anyone can recommend a good online C++ tutorial?
我老版问我How to run a mpi job only on local host??
[合集] 很弱的c++ recompiling 的问题compile error about : GetServerURL
弱问C++一个问题 一直不解Google Web Toolkit 令人失望 (转载)
问个C++ Segmentation Fault的问题从统一数据格式和算法写作格式的角度讲,matlab还是很先进的
相关话题的讨论汇总
话题: member话题: add话题: libraries话题: class话题: destructor
进入Programming版参与讨论
1 (共1页)
f*******y
发帖数: 988
1
【 以下文字转载自 Quant 讨论区 】
发信人: yayadoudou (yayadou), 信区: Quant
标 题: 问个面试问题,请教
发信站: BBS 未名空间站 (Fri Jun 20 14:05:58 2008)
You have a class that many libraries depend on. Now you need to modify the
class for one application. Which of the following changes require
recompiling all libraries before it is safe to build the application?
a. add a constructor
b. add a data member
c. change destructor into virtual
d. add an argument with default value to an existing member function
f*******y
发帖数: 988
2
帮你转这里,呵呵

【在 f*******y 的大作中提到】
: 【 以下文字转载自 Quant 讨论区 】
: 发信人: yayadoudou (yayadou), 信区: Quant
: 标 题: 问个面试问题,请教
: 发信站: BBS 未名空间站 (Fri Jun 20 14:05:58 2008)
: You have a class that many libraries depend on. Now you need to modify the
: class for one application. Which of the following changes require
: recompiling all libraries before it is safe to build the application?
: a. add a constructor
: b. add a data member
: c. change destructor into virtual

O*********y
发帖数: 633
3
I assume you will compile the lib into dll not static lib file.
My answer might be wrong but in this case I will choose C. change destructor
into virtual.
The reason is in the run time, other library based on this class may try to
find a non-virtual destructor directly instead of look up a vtable because
the class user wasn't given information that the destructor now is virtual.
Please correct me if I am wrong.
v**u
发帖数: 20
4
My answer is b, add data member changed object type, it requires all
dependent library.
f******y
发帖数: 2971
5
我选b,因为b可能需要DA。
s******e
发帖数: 431
6
如果这个data member 加在最后, 应该也没有影响。我选C

【在 f******y 的大作中提到】
: 我选b,因为b可能需要DA。
s*****d
发帖数: 43
7
Are we limited to only 1 answer?
b, c, d
d is in because the caller of this function will have to recompile and
relink.
n**d
发帖数: 9764
8
It depends on how many libraries the application uses too. At least the
libraries used by this application need to be re-built.

function

【在 f*******y 的大作中提到】
: 帮你转这里,呵呵
s*******d
发帖数: 59
9
c++,c#,java Object Memory Layout,哪儿有详细资料吗?
O*********y
发帖数: 633
10
After some tests, the answer looks like to be B, C and D.
Something worth mention:
For C, if add a data member after the last existing declared data member,
libs depending on this class may not need to be re-compiled. If the newly
added data member is inserted between two existing data member declaration,
libs depending on this class need to be re-compiled.
for D, if add a arguments and assign a default value to it, all derived libs
need to be re-compiled.
s*******d
发帖数: 59
11
添加一个member在最后,虽然能link,但并不等于没问题。
lib里分配的内存大小是错的。
M**8
发帖数: 25
12
This post is cross posted. Should mention it in the initial post, IMHO.
http://www.mitbbs.com/article_t/Computation/31159531.html
O*******d
发帖数: 20343
13
Adding a member may change the size of an object, requiring recompilation of
all code that use this class.

,
libs

【在 O*********y 的大作中提到】
: After some tests, the answer looks like to be B, C and D.
: Something worth mention:
: For C, if add a data member after the last existing declared data member,
: libs depending on this class may not need to be re-compiled. If the newly
: added data member is inserted between two existing data member declaration,
: libs depending on this class need to be re-compiled.
: for D, if add a arguments and assign a default value to it, all derived libs
: need to be re-compiled.

1 (共1页)
进入Programming版参与讨论
相关主题
从统一数据格式和算法写作格式的角度讲,matlab还是很先进的我老版问我
问大牛个java线程机器数的估算[合集] 很弱的c++ recompiling 的问题
c++ define 一问弱问C++一个问题 一直不解
C++小插曲问个C++ Segmentation Fault的问题
问个题。A C++ compiler related interview question
[合集] C++ interview question help一道面试怪题C++. (转载)
急问:compile and build dependencyStrange problem with CGI (转载)
third party c/c++ code and compile it on win 7Anyone can recommend a good online C++ tutorial?
相关话题的讨论汇总
话题: member话题: add话题: libraries话题: class话题: destructor