0

When I put return; or return void(); in a regular void method of the C++ class in Qt 5 it compiles ok. When I put it in a slots method the compiler generates the following error:

error C2120: 'void' illegal with all types

Here it is stated, that a return in void is possible: Can I return in void function?

Here it is stated, that since slots are normal C++ functions one may return value, including void, I presume. http://www.qtcentre.org/archive/index.php/t-26724.html

Any ideas why a C2120 is issued under those circumstances?

Community
  • 1
  • 1
scopchanov
  • 7,966
  • 10
  • 40
  • 68

1 Answers1

0

you can only return void from a void function. For example:

void foo()
{
  return void();
}

else you can return like

void foo()
{
  return;
}

which is void in itself.

as stated in that example, but you cannot return anything else, That is why there is an error.

Mukul Chauhan
  • 120
  • 1
  • 1
  • 10