This simple code won't compile:
#include <cstdio>
#include <boost/thread.hpp>
struct ftor{
void operator()(){ printf("Hello"); }
};
int main()
{
boost::thread th( ftor() );
th.join(); //<--- error C2228: left of '.join' must have class/struct/union
}
But, following code well compiled:
#include <cstdio>
#include <boost/thread.hpp>
struct ftor{
void operator()(){ printf("Hello"); }
};
int main()
{
ftor f;
boost::thread th( f );
th.join();
}
Q:
What's problem with #1 code ?
I use visual studio 2010 .
Update: codepade http://codepad.org/r5Aok406 shows more informative error:
Line 19: error: request for member 'join' in 'th', which is of non-class type 'mythread ()(ftor (*)())'