-1

I have the signature of the function in my .hpp file and the definition in my .cpp file.

I get a linker error every time I try this, but it goes away and works just fine as soon as I remove the word 'inline'.

3
  • 2
    Please include a Minimal, Complete, and Verifiable example. Commented Oct 25, 2016 at 19:24
  • Short answer: you do not Commented Oct 25, 2016 at 19:25
  • The whole point of inline is to allow you to place the function definition in the header. If you are trying to use inline to tell the compiler to inline the function, don't worry about it; modern compilers will inline functions that they deem appropriate, regardless of whether or not you give the inline keyword. Commented Oct 25, 2016 at 19:41

1 Answer 1

2

An inline function must be defined in every translation unit in which it is odr-used. If you want the function to be inline, you need to define it in the header. If you want to declare it in the header and define it in the .cpp file, then don't mark it inline.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.