This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/34727] problem with templates and inheritence



------- Comment #2 from isenbaev at gmail dot com  2008-01-10 01:20 -------
Sorry there was a missprint in a test code, here is a correct example:

template<class T>
class A
{
public:
        T x;
};

template<class T>
class B : public A<T>
{
public:
        void clear()
        {
                x = 0;
        }
};

B<int> b;

int main()
{
        b.x = 0;
        b.clear();
        return 0;
};

This fails with message

test.cpp: In member function `void B<T>::clear()':
test.cpp:14: error: `x' was not declared in this scope

Also, if we try to access b.x from outside, it works. That is, if we comment
the line "x = 0;" in clear function, it compiles.

If this code is wrong, please tell me why? Some other compilers compile this,
and some don't.


-- 

isenbaev at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34727


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]