Discard an unused virtual method

Here is an example illustrating my problem:

class Foo1
{
  virtual void FooMethod() __attribute__((deprecated)) = 0;
};

class Foo2  : public Foo1
{
  virtual void FooMethod() = 0;
};

My class Foo1has a pure virtual method FooMethod. I do not want the user to use it anymore. I want them to use this method in an inherited class Foo2. Foo1::FooMethod()so outdated and placed in Foo2: Foo2::FooMethod(). Foo2::FooMethod()is then an overrideFoo1::FooMethod();

If the user tries to reload Foo1::FooMethod(), he will receive a compilation warning. My problem is that if the user overrides Foo2::FooMethod(), he also gets a warning.

How can I implement "Overload is Foo1::FooMethod()out of date, you must override FooMethod()through Foo2." I can not remove Foo1::FooMethod()for compatibility.

Thank!

+1
1

"Overload Foo1:: FooMethod() , FooMethod() Foo2". Foo1:: FooMethod() .

(: P), .

, , .

0

Source: https://habr.com/ru/post/1694187/


All Articles