avatar
问个面试问题,请教# Programming - 葵花宝典
h*h
1
本人的表弟在一国际会议上发表了一篇论文,但是他无法及时获得美国签证,因此
它不能按时参加会议。 会议组织者回复说作者可以找人代读。
代读的报酬: 代读者将作为第二作者。并有一定报酬。
该国际会议将于四月二十四-六日在洛杉矶以东( ~40 miles) 的pomona小镇举
行。
http://www.csupomona.edu/~wtsi/
I am looking for a graduate student from Unversities (UCLA, UCI, CalTech,
etc) in LA. If you are interested in this. Please send an email to my
mailbox (r********[email protected]).
Thanks a lot in advance!
Nick
avatar
f*y
2
【 以下文字转载自 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
avatar
J*r
3
sigh,还得是名校的

CalTech,

【在 h***h 的大作中提到】
: 本人的表弟在一国际会议上发表了一篇论文,但是他无法及时获得美国签证,因此
: 它不能按时参加会议。 会议组织者回复说作者可以找人代读。
: 代读的报酬: 代读者将作为第二作者。并有一定报酬。
: 该国际会议将于四月二十四-六日在洛杉矶以东( ~40 miles) 的pomona小镇举
: 行。
: http://www.csupomona.edu/~wtsi/
: I am looking for a graduate student from Unversities (UCLA, UCI, CalTech,
: etc) in LA. If you are interested in this. Please send an email to my
: mailbox (r********[email protected]).
: Thanks a lot in advance!

avatar
f*y
4
帮你转这里,呵呵

【在 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

avatar
O*y
5
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.
avatar
v*u
6
My answer is b, add data member changed object type, it requires all
dependent library.
avatar
f*y
7
我选b,因为b可能需要DA。
avatar
s*e
8
如果这个data member 加在最后, 应该也没有影响。我选C

【在 f******y 的大作中提到】
: 我选b,因为b可能需要DA。
avatar
s*d
9
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.
avatar
n*d
10
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 的大作中提到】
: 帮你转这里,呵呵
avatar
s*d
11
c++,c#,java Object Memory Layout,哪儿有详细资料吗?
avatar
O*y
12
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.
avatar
s*d
13
添加一个member在最后,虽然能link,但并不等于没问题。
lib里分配的内存大小是错的。
avatar
O*d
15
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.

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