Fixng unused formal parameter warnings without creating an abstract class

I have a base class and it has virtual functions. The problem is that the database is allowed to be instantiated, but this means that all of its functions need to be defined. This causes the compiler to warn me of unused parameters. What can I do to get rid of these warnings correctly without creating pure virtual functions and making it an abstract class?

Example:

class Foo {
public:
virtual void bar(int x) {} //unused formal parameter int x
}

thank

+3
source share
3 answers

The usual solution:

virtual void bar(int x) { (void)x; }

or

virtual void bar(int) {}

. , -; , .

; - ; , ?

+14

?

class Foo {
public:
  virtual void bar(int) {}
};

.

+2

What is an alternative method for:

virtual void bar(int /*x*/) {}
+1
source

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


All Articles