The following MWE fails to compile in VS 2008
Bar.h
struct Bar
{
Bar();
};
Bar.cpp
#include "Bar.h"
Bar::Bar()
{
}
Foo.h
#include "Bar.h"
template<typename T>
class Foo
{
public:
Foo()
{
}
private:
Bar m_bar;
};
main.cpp
#include "Foo.h"
int main()
{
Foo<int> f;
return 0;
}
Error message:
error LNK2019: unresolved external symbol "public: __thiscall Bar::Bar(void)" (??0Bar@@QAE@XZ) referenced in function "public: __thiscall Foo<int>::Foo<int>(void)" (??0?$Foo@H@@QAE@XZ)
However the same code successfully compiles in GCC 3.4.4 -- old compiler I know, but its currently the latest version that I've got on my machine. Is this code standard compliant or is this a VS 2008 bug?