Using an undeclared identifier with patterns and subsequent subsequent inheritance

I had the same problem as in the previous question: Using an undeclared identifier in C ++ with templates and inheritance

To summarize, we are trying to access the protected attribute of a template class from a child class. The described way to do this will use this->attributeinstead attribute. The fact is, I was wondering how in Visual Studio 2012 it was not necessary to add this-> before referring to a variable to compile and execute the program properly. I was also wondering if there is a way to use this function in gcc or other compilers on OS X.

EDIT: Here is the code I used to test this in visual studio 2012.

//file a.h

template<class T>
class a
{
public:
    a(){value = 2;};
protected:
    T value;
};

template<class T>
class b: public a<T>
{
public:
    T getValue(){return value;};
};

//file main.cpp
#include <iostream>
#include "a.h"
using namespace std;
int main()
{
    b<int> myTest;
    cout<<myTest.getValue();
    system("pause");
    return 0;
}

g++, visual studio 2012.

+5
1

, , , , - Β§14.6.2/3, :

, , , .

, . . , GCC , 4.7 ( # 24163, 29131). , Visual Studio. , . , .

+4

All Articles