问题
Here's an example to illustrate my issue :
class Foo1
{
virtual void FooMethod() __attribute__((deprecated)) = 0;
};
class Foo2 : public Foo1
{
virtual void FooMethod() = 0;
};
My class Foo1
has a pure virtual method FooMethod
. I don't want user to use it anymore. I want to make them use this method in the inherited class Foo2
.
Foo1::FooMethod()
is so deprecated and put in Foo2
: Foo2::FooMethod()
. Foo2::FooMethod()
is then an override of Foo1::FooMethod();
If the user try to overload Foo1::FooMethod()
, he will get a compilation warning.
My issue is, if the user override Foo2::FooMethod()
, he also gets a warning.
How can I implement "Overload Foo1::FooMethod()
is deprecated, you must override FooMethod()
through Foo2
". I can't delete Foo1::FooMethod()
for compatibility.
Thanks !
回答1:
How can I implement "Overload Foo1::FooMethod() is deprecated, you must overload FooMethod() through Foo2". I can't delete Foo1::FooMethod() for compatibility.
At this point, you're causing such a mess in your design (:P) that I would stick with documentation.
Tell your users that the function is deprecated and shouldn't be used, then move on.
来源:https://stackoverflow.com/questions/21049654/deprecate-unused-virtual-method