[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem with using and templated base class
From: |
Roger Leigh |
Subject: |
Problem with using and templated base class |
Date: |
Sun, 06 May 2007 23:26:32 +0100 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) |
Hi folks,
I'm having a problem with using a "using" directive to use a type in a
base class in a derived class. A typedef of the same thing does work
however:
class other
{
public:
typedef int foo;
};
template <typename T>
class base
{
public:
T something;
typedef other::foo bar;
};
template <typename T>
class derived : public base<T>
{
using base<T>::bar; // This does not work.
//typedef other::foo bar; // This does work.
void breaks()
{
bar baz;
baz = 4;
}
};
int main()
{
derived<int> var;
}
% g++ -Wall -pedantic -o test test.cc
test.cc: In member function ‘void derived<T>::breaks()’:
test.cc:23: error: expected `;' before ‘baz’
test.cc:24: error: ‘baz’ was not declared in this scope
test.cc: In function ‘int main()’:
test.cc:30: warning: unused variable ‘var’
Is this an issue with GCC, or am I using incorect syntax here?
Many thanks,
Roger
--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
pgpF9wUWx6_j2.pgp
Description: PGP signature
- Problem with using and templated base class,
Roger Leigh <=