English 中文(简体)
是否将公共非虚拟方法重新排列在一个单独的班级中?
原标题:Does reordering public non-virtual methods in a stand-alone class break ABI?
  • 时间:2012-05-10 15:05:27
  •  标签:
  • c++
  • abi

在一个独立类别中改变非硬性公共超载方法的顺序是否打破了《反导条约》?

此前:

class MyFinalClass
{
public:
    // ...
    void doSomething(char c, int i, int n);
    void doSomething(char c, int i);
    // ...
};

After:

class MyFinalClass
{
public:
    // ...
    void doSomething(char c, int i);
    void doSomething(char c, int i, int n);
    // ...
};

感谢!

最佳回答

这些职能按其名称和签名,而不是按其在该类别中的地位加以联系。 因此,你不再打断ABI。

虚拟功能是一个不同的问题,因为它们按其立场(通常)重新联系起来。 如果你始终不.地篡改每个档案,而这些档案取决于确定该命令的负责人,那么,如果在图书馆中存在这一类别,那就是一个问题。

问题回答

在你更新课堂时,有两点打破了考试和测验局。 Mark指出的虚拟职能(并记住,这不是因为你没有把其作为虚拟的标志。)

其它事项是在线职能,因为它们利用了你的变数成员。 如果您的变数成员顺序发生变化,则其他软件中汇编的星号也会中断。

正如Russel Greene所指出的(见评论),变数成员的顺序也可能造成调和差异,足以改变分配物体的规模。 这也打破了你的分配(假设客户代码的使用new)。

加上/移走成员可能不会打破《反种族歧视公约》(现在仍然可以在这里分配一字或一字......),但通常会给他们一个交易商。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签