Advertisement

strangeness in gcc 4.0

Started by August 29, 2005 04:28 AM
0 comments, last by Crispweed 19 years, 3 months ago

template <class TRAITS>
class cBase
{
public:
    long dataMember;
};
template <class TRAITS>
class cDerived : public cBase<TRAITS>
{
public:

    void foo()
    {
        cBase<TRAITS>::dataMember = 5; // this works ok
        this->dataMember = 5; // this works ok
        dataMember = 5; // this causes an error with dataMember not found
    }
};

When I attempt to compile this I get: Test.cpp:17 error: 'dataMember' was not declared in this scope Has anyone had similar problems in gcc 4.0? If someone else here is using gcc 4.0 please try compiling this and see if you get the same problem..

Ok, apparently this is how it is supposed to work:

from http://gcc.gnu.org/gcc-3.4/changes.html:

"In a template definition, unqualified names will no longer find members of a dependent base (as specified by [temp.dep]/3 in the C++ standard). "

This topic is closed to new replies.

Advertisement