At Calling a static method by repeating the object name, I see the following code.
struct foo {
static foo& instance() {
static foo f;
return f;
}
};
And
foo::foo::foo::instance();
works fine.
However, at expected type-specifier and cannot convert ‘int*’ in initialization, I see the following code:
namespace ASP
{
class ASp
{
public:
ASp();
ASp(FILE* fp);
};
}
But
using namespace ASP;
ASp* asp = new ASp::ASp();
fails to compile in g++ 4.8.2 and Visual Studio 2010.
g++ reports:
error: expected type-specifier
ASp* asp = new ASp::ASp();
Visual Studio reports:
error C2061: syntax error : identifier '{ctor}'
Why does injected class name work for the first case and not for the second case?