How to inline member functions?

Started by
4 comments, last by Boogsie 21 years, 3 months ago
Hi First off, I am using Visual Studio .NET. I am trying to inline member functions of a class. When I add the inline keyword to either the prototype in the class definition or the function itself, the program compiles, but the linker complains that the function is missing, and lists the place where the function is being called from. Particles error LNK2019: unresolved external symbol "public: void __thiscall CParticleEngine::AddParticle(unsigned long,class CParticle *)" (?AddParticle@CParticleEngine@@QAEXKPAVCParticle@@@Z) referenced in function "public: bool __thiscall CParticleEmitter::Update(float)" (?Update@CParticleEmitter@@QAE_NM@Z) Can anyone help me? Thanks
Advertisement
Inline member functions must be either inline, or be defined in the header file.


  class foo{   void bar()   {      // do some stuff...   }   void baz();};inline void foo::baz(){   // do some other stuff...}  



Update GameDev.net system time campaign: 'date ddmmHHMMYYYY'

[edited by - dalleboy on January 20, 2003 5:03:49 AM]
Arguing on the internet is like running in the Special Olympics: Even if you win, you're still retarded.[How To Ask Questions|STL Programmer's Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN]
Thanks!

Putting member functions in the class declaration (bar in dalleboy''s example) guarantees inlining. Using the inline keyword (baz) does not guarantee inlining.
quote:Original post by Anonymous Poster
Putting member functions in the class declaration (bar in dalleboy''s example) guarantees inlining. Using the inline keyword (baz) does not guarantee inlining.

got a source to back this up?
Thanks!

This topic is closed to new replies.

Advertisement