I have a binary that has always existed. It has a class C that it has always existed as well. We have to introduce a new method M to the class C but we only want some users to be aware of the existence of such method M.
我有一个一直存在的二进制文件。它有一个C级,它一直存在。我们必须向C类引入一个新的方法M,但我们只希望一些用户知道这种方法M的存在。
By removing from the .h file such method, which problem we can introduce? Will such approach be backward compatible?
通过从.h文件中删除这样的方法,我们可以介绍哪个问题?这种方法是否会向后兼容?
EDIT: We actually don't care if there's a way to find the method. We just want to make sure that only people knowing what they're doing, use it.
编辑:我们实际上并不关心是否有办法找到方法。我们只想确保只有人知道他们在做什么,才能使用它。
2 个解决方案
#1
With most C++ compilers: if the method is virtual you'll be in serious trouble (the vtable will be all messed up); if the method is NOT virtual you shouldn't be (but some smart user will deduce the existence of what you're trying to hide via "security through obscurity" and find ways to use the method you'd rather keep hidden from him -- but that's another story;-).
对于大多数C ++编译器:如果方法是虚拟的,那么你将遇到严重问题(vtable将全部搞砸);如果这个方法不是虚拟的,你不应该是(但是一些聪明的用户会通过“默默无闻”来推断出你想要隐藏的东西的存在,并想方设法使用你宁愿隐藏的方法 - - 但这是另一个故事;-)。
#2
A safer method would be to simply make a derived class and give that one's .h only to certain people.
一种更安全的方法是简单地创建一个派生类,并仅将某个人的.h给予某些人。
#1
With most C++ compilers: if the method is virtual you'll be in serious trouble (the vtable will be all messed up); if the method is NOT virtual you shouldn't be (but some smart user will deduce the existence of what you're trying to hide via "security through obscurity" and find ways to use the method you'd rather keep hidden from him -- but that's another story;-).
对于大多数C ++编译器:如果方法是虚拟的,那么你将遇到严重问题(vtable将全部搞砸);如果这个方法不是虚拟的,你不应该是(但是一些聪明的用户会通过“默默无闻”来推断出你想要隐藏的东西的存在,并想方设法使用你宁愿隐藏的方法 - - 但这是另一个故事;-)。
#2
A safer method would be to simply make a derived class and give that one's .h only to certain people.
一种更安全的方法是简单地创建一个派生类,并仅将某个人的.h给予某些人。