You got this error because you put func’s definition in the class body and it’s small enough, so, first, the compiler inlined this function —- that means, the compile will substitute all the appearance of this function’s call with its definition, and no definition of this function will be in the executable file. And, second, you didn’t really call that function in your program, so in fact, this function never exist in your final executable file!
To solve that:
- You can put the definition of func outside the class body.
- Call func in your program anywhere.