c**********e 发帖数: 2007 | 1 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
This is an old question. I believe that it was discussed before. But I am
still not sure about its answer. |
w****r 发帖数: 1384 | 2 c
【在 c**********e 的大作中提到】 : 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 : This is an old question. I believe that it was discussed before. But I am : still not sure about its answer.
|
t*****j 发帖数: 1105 | 3 选c是因为会改变其他子类的vtable,所以要重编译,对吗? |
n******n 发帖数: 12088 | 4 因为abd都不对。
【在 t*****j 的大作中提到】 : 选c是因为会改变其他子类的vtable,所以要重编译,对吗?
|
s****a 发帖数: 528 | |
s****a 发帖数: 528 | 6 add data member will change the memory size of the object. and even
arrangement of the data member. |
t*****j 发帖数: 1105 | 7 其实我也倾向选b。呼唤正确答案!
【在 s****a 的大作中提到】 : add data member will change the memory size of the object. and even : arrangement of the data member.
|
m*****n 发帖数: 2152 | 8 如果这个class原来没有virtual function, 现在加了一个,object size也是变化的因为多了
vtable,这样和b的情况一样了。 |
c**********e 发帖数: 2007 | 9 呼唤xnxky and thrust两位高手!
【在 t*****j 的大作中提到】 : 其实我也倾向选b。呼唤正确答案!
|
s*****n 发帖数: 5488 | 10 C++必须转化成C.如果数据变了对于其他lib没有任何影响,不需要重新compile,ld.
但是函数的signature变了。则必须重新编译才能知道正确的接口。所以只能是b.
【在 s****a 的大作中提到】 : add data member will change the memory size of the object. and even : arrangement of the data member.
|
t*****j 发帖数: 1105 | 11 我觉得我思路可能错了,vtable应该是实例中才有的,也就是运行时候才有,和编译没
有关系。
这么排除下来应该还是b。
的因为多
了
【在 m*****n 的大作中提到】 : 如果这个class原来没有virtual function, 现在加了一个,object size也是变化的因为多了 : vtable,这样和b的情况一样了。
|
d**e 发帖数: 6098 | 12 http://www.mitbbs.com/bbsann2/life.faq/JobHunting/17/D12842543542i0/M.1284348203_2.70/%CE%CA%B8%F6C%2B%2B%D6%D8%D0%C2%B1%E0%D2%EB%B5%C4%CE%CA%CC%E2
【在 c**********e 的大作中提到】 : 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 : This is an old question. I believe that it was discussed before. But I am : still not sure about its answer.
|