avatar
a c++ interview question# JobHunting - 待字闺中
w*l
1
【 以下文字转载自 Quant 讨论区 】
发信人: wiseseal (wiseseal), 信区: Quant
标 题: a c++ interview question
发信站: BBS 未名空间站 (Wed Oct 7 22:37:51 2009, 美东)
You have a class that many libraries depend on. Now you need to modify the c
lass 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
c*r
2
c

c
recompiling

【在 w******l 的大作中提到】
: 【 以下文字转载自 Quant 讨论区 】
: 发信人: wiseseal (wiseseal), 信区: Quant
: 标 题: a c++ interview question
: 发信站: BBS 未名空间站 (Wed Oct 7 22:37:51 2009, 美东)
: You have a class that many libraries depend on. Now you need to modify the c
: lass 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
w*l
3
a definitely do not need, b will need,
c and d not sure...

【在 c*****r 的大作中提到】
: c
:
: c
: recompiling

avatar
S*g
4
what if you add a constructor with parameters when the original code
does not have any constructor and relies on the default constructor
generated by the compiler?

【在 w******l 的大作中提到】
: a definitely do not need, b will need,
: c and d not sure...

avatar
w*l
5
yes, u r right. I missed this point.
d will need as well.
c is interesting, I guess change destructor to virtual only
has an impact if the original code uses a base class pointer
to delete the derived class object. But if the original code
is like that and the destructor is not virtual, it would not be correct ?

【在 S*********g 的大作中提到】
: what if you add a constructor with parameters when the original code
: does not have any constructor and relies on the default constructor
: generated by the compiler?

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