deprecate unused virtual method

ぃ、小莉子 提交于 2019-12-11 09:25:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!