This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc 3.4.5: Partially specialized descendant of template doesn't see members of base
- From: "Dima Sorkin" <dima dot sorkin at gmail dot com>
- To: Mazzzy2005 at yandex dot ru
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 8 Oct 2006 15:27:21 +0200
- Subject: Re: gcc 3.4.5: Partially specialized descendant of template doesn't see members of base
- References: <1629767664.20061007160840@yandex.ru>
Hi.
See my remarks with "///".
Regards,
Dima.
On 10/7/06, Mazay wrote:
template <class T>
class Der<T,4>: public Base<T>
{
public:
using Base<T>::x; //!!
/// I think this is misuse of "using". "using" in a class scope is
intended for
/// disambigation in the case of multiple inheritance.
template <class T,int num>
int Der<T,num>::get()
{
return x-num;
/// I don't know why compiler does not shout on this one, see below.
}
template <class T>
int Der<T,4>::get()
{
return x+4; //38 row. The error is here. x is not declared in this scope.
/// It should be "this->x". Otherwise compiler should shout, because
of two pass
/// compilation of the templates, it cannot know what is "x".
}
Compilation output:
---------------------------------------------------------
C:\prg\test\mingw_templ>g++ main.cpp
main.cpp: In member function `int Der<T, 4>::get()':
main.cpp:38: error: `x' was not declared in this scope
---------------------------------------------------------
Compiler version information:
---------------------------------------------------------
C:\prg\test\mingw_templ>g++ -v
Reading specs from C:/Install/MinGW/bin/../lib/gcc/mingw32/3.4.5/specs
Configured with: ../gcc-3.4.5/configure --with-gcc --with-gnu-ld --with-gnu-as