由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问个C++重新编译的问题
相关主题
C++ Q65: recompiling (IB)Two C++ questions from Bloomberg on-site
请教1个工作面试题one C++ question?
一道面试的选择题virtual destructor (C++)问题
a c++ interview question问几个跟C++有关的面试题
这个题目的讨论的结论是什么问一个constructor的问题
问个C++题c++ vs Java virtual 实现(Y家)
virtual destructor的地址在virtual table里面吗?新Qualcomm面经
C++ online Test 一题包子呼唤大牛--问关于C++Destructor的问题 (转载)
相关话题的讨论汇总
话题: add话题: class话题: member话题: libraries
进入JobHunting版参与讨论
1 (共1页)
a****l
发帖数: 245
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
J******d
发帖数: 506
2
Someone asked this question before.

function

【在 a****l 的大作中提到】
: 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

r**u
发帖数: 1567
3
c

function

【在 a****l 的大作中提到】
: 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

a****l
发帖数: 245
4
忘说了,我也记得有人问过了,当时没在意,又找不到帖子,所以发了新帖

【在 J******d 的大作中提到】
: Someone asked this question before.
:
: function

a****l
发帖数: 245
5
能否具体解释下?

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

a****n
发帖数: 1887
6
都需要。。
a. add a constructor
如果class只有default constructor, 加入新的constructor, client code
A a; 就不work了
b. add a data member
class layout 改变, 肯定要重新编译,
c. change destructor into virtual
如果原class 没有vtable, 这个会改变class layout
d. add an argument with default value to an existing member function
函数签名改变, 调用到该函数的程序,需要重新编译
c****p
发帖数: 32
7
嗯,但是也可以从另一个方面来说不需要recompile.

如果已经explicitly 有了其他ctor,加入新的没有影响。
这个基本上是要重新compile,一个例外是加入原来的class本来就只是method的封装比
如:
class Methods
{
public:
staic void test1();
}
这样加入new member fields也没什么关系(但是如果client code有类似sizeof(
Methods)的就不行)
这个一定要重新compile.其他的例子都可以找到反例(虽然有点急转弯的意思),但是
因为dtor是一定要被用到的,如果原本的dtor变成virtual,那么client端整个调用过
程就变了。原来是:
$Class_Dtor();
变成virtual后变成了
pClass->vtbl[index_of_dtor]();
所以client端必须重新compile.
反例是如果这个member function根本就没用到:D

【在 a****n 的大作中提到】
: 都需要。。
: a. add a constructor
: 如果class只有default constructor, 加入新的constructor, client code
: A a; 就不work了
: b. add a data member
: class layout 改变, 肯定要重新编译,
: c. change destructor into virtual
: 如果原class 没有vtable, 这个会改变class layout
: d. add an argument with default value to an existing member function
: 函数签名改变, 调用到该函数的程序,需要重新编译

a****l
发帖数: 245
8
谢谢各位的回答
1 (共1页)
进入JobHunting版参与讨论
相关主题
包子呼唤大牛--问关于C++Destructor的问题 (转载)这个题目的讨论的结论是什么
C++面试问题,高人请进啊~~~问个C++题
为什么C++的constructor出错可以抛出异常,而destructor出错virtual destructor的地址在virtual table里面吗?
One C++ questionC++ online Test 一题
C++ Q65: recompiling (IB)Two C++ questions from Bloomberg on-site
请教1个工作面试题one C++ question?
一道面试的选择题virtual destructor (C++)问题
a c++ interview question问几个跟C++有关的面试题
相关话题的讨论汇总
话题: add话题: class话题: member话题: libraries