When auto
is used as the return type in a function declaration that does not use the trailing return type syntax, the keyword auto
indicates that the return type will be deduced from the operand of its return statement. That means the deduction can't be performed until the definition of the function func()
, but before that it has been used in main()
.
You could move the definition before main()
, or use trailing return type syntax to specify the return type on the declaration.