inline functions
Hi, I have a class like this
mesh.h
class Mesh
{
public:
...
inline int GetMaterial();
private:
...
int materialIndex;
};
and in mesh.cpp
inline int Mesh :: GetMaterial()
{
return materialIndex;
}
But when Visual C++ links, there''s an unresolved external error:
Mesh::GetMaterial
If I define it like this in the class
int GetMaterial() { return materialIndex; };
it works
Why ?
Thanks
I believe that the inline function code must be in the .h... like
//--a.h--
class a
{
public:
void foo();
};
inline void a::foo()
{
}
that should work, if not, don''t kill me
----------------------------
noxa - Ben Vanik
http://24.3.123.4
----------------------------
//--a.h--
class a
{
public:
void foo();
};
inline void a::foo()
{
}
that should work, if not, don''t kill me
![](smile.gif)
----------------------------
noxa - Ben Vanik
http://24.3.123.4
----------------------------
----------------------------noxa - Ben Vanikhttp://24.3.123.4----------------------------
quote:
Original post by Mezz
It doesn''t have to be, but don''t specify inline twice.
-Mezz
I think it has to be in the *.h to work correctly. I made really weird experiences exporting inline functions to *.cpp.
Sometimes, I got a compiler error, sometimes it compiled, but didn''t inline and so on. (compiled with BCB5)
Wunibald
(Computer && !M$ == Fish && !Bike)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement