This topic is 3317 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have this function:
Sint16 Sprite::y() const
{
return offset.y;
}


If I change it to this:
inline Sint16 Sprite::y() const
{
return offset.y;
}


error LNK2019: unresolved external symbol "public: short __thiscall Sprite::y(void)const " (?y@Sprite@@QBEFXZ) referenced in function _SDL_main I'm using Visual C++ 2008 EE

##### Share on other sites
This should work, are you sure that the cpp file in which this definition resides is visible (is it included in the project). When you get the unresolved external error that usually means that the linker cannot find the location where the function is defined ( that can happen from a mismatch of the function signature, such as when you define a function as const in declaration and not in definition or vise-versa, so you should check that the signatures are the same ) Hope this helps.

##### Share on other sites
declaration: (inside the class) in sprite.h

Sint16 Y() const;

and definition:

inside sprite.cpp

inline Sint16 Sprite::Y() const
{
return offset.y;
}

##### Share on other sites
An inline function must be defined in every translation unit in which it is used. In practice this means that it has to go inside a header file.

##### Share on other sites
Quote:
 Original post by SiCraneAn inline function must be defined in every translation unit in which it is used. In practice this means that it has to go inside a header file.

That explains it, thanks.