Topic: [Bug++] Template Instantiation Rule


Author: "Phlip C Plumlee" <tegan@deltanet.com>
Date: 1997/11/12
Raw View
 Sowmy wrote in article
<01bcee66$f2e80ca0$cb335295@sowmy_W95.attachmate.com>...

>template<class _Ty >
>class T{
>public:
> void Do(const _Ty& _X = _Ty()){}
>};
>
>class A{
>public:
>  class B{int b;};
>  T<B> t;
>};
>
>The above code gives a compilation error. Undeclared identifier in "B" in
>Line "void Do(const _Ty&rn _X = _Ty()){}"
>
>Apparently it looks like that the compiler (I am using the Microsoft's
>VC++ 5.0) is...

...screwing up nested class scope resolution again. This is a well-known bug
(to me, at least). The compiler can't figure out what '= _Ty()' is because
it accidently goes back to global scope.

The simplistic fix is this:

    class B{int b;};

    class A{public:
    T<B>t;
    };

But of course A lost lost the ability to control the public's access to B.

I have CC'd your bug to Windows Developers Journal - they have a monthly
Bug++ feature.

I can't _afford_ to send a bug report to you-know-who...

  --  Phlip
======= http://users.deltanet.com/~tegan/home.html =======
  --  All sensors report Patti having a very good time  --
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]