Here are the codes, which work fine under g++
, but give error under VC++ 2014
:
template <class A>
struct Expression
{
public:
static const int status = A::status_;
};
struct Foo : public Expression<Foo>
{
static const int status_ = 0;
};
int main(void) {
return 0;
}
Why ? Thanks!
The error messages are:
error C2039: 'status_': is not a member of 'Foo'
error C2065: 'status_': undeclared identifier
error C2131: expression did not evaluate to a constant
Define status
and it will work. See below. As for standard, I do not know which compiler is correct.
template <class A>
struct Expression
{
public:
static const int status;
};
struct Foo : public Expression<Foo>
{
static const int status_ = 0;
};
template< typename A >
const int Expression<A>::status = A::status_;
int main( void ) {
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With