t**g 发帖数: 1164 | 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
我选的是b,c
理由是它们会改变class的size
请问是对的么
谢谢! |
m*******i 发帖数: 370 | 2 我也遇到这个题了,co-ask
function
【在 t**g 的大作中提到】 : 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 : 我选的是b,c : 理由是它们会改变class的size : 请问是对的么
|
B*****t 发帖数: 335 | 3 my answer is bcd require recompiling, a depends.
function
【在 t**g 的大作中提到】 : 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 : 我选的是b,c : 理由是它们会改变class的size : 请问是对的么
|
m*******i 发帖数: 370 | 4 弱弱的问,为啥增加data member要recompile啊?已经存在的client program肯定没有
用这个data member的啊。
【在 B*****t 的大作中提到】 : my answer is bcd require recompiling, a depends. : : function
|
B*****t 发帖数: 335 | 5 <>第一章讲的很明白,主要是C++没有定义二进制层面上的封装。
比如class A的大小是4byte,你又增加了4byte,如果不recompile,这增加的4byte在
你的code很可能属于其他object所拥有。如果你继续使用这个类,而这个类又会对这新
增的4byte进行写操作,很显然会破坏你原有的code。
大部分情况下runtime error!
【在 m*******i 的大作中提到】 : 弱弱的问,为啥增加data member要recompile啊?已经存在的client program肯定没有 : 用这个data member的啊。
|
h**6 发帖数: 4160 | 6 还有,分配内存的时候sizeof的结果是写死在二进制文件里的,需要重新编译改为8字
节。 |