Topic: Migrating to ISO C++


Author: Terence Kelling <kelling@arlut.utexas.edu>
Date: 1998/07/07
Raw View
I just compiled your example with MS Visual C++ ver 5 and didn't have any
errors either.

Terence Kelling



[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Matthias Mueller <matthias@ica1.uni-stuttgart.de>
Date: 1998/07/02
Raw View
The code compiles well with
gcc 2.8.1
egcs-19980621 snapshot
cxx 6.x (DEC)
KCC 3.3c ( Kuck and Associates)
SUNpro CC (SUN)
xlC (IBM)
with and without strict ansi flags.

Maybe aCC is just wrong.

Matthias

--


[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: zeisel@lnzx16.vai.co.at (Zeisel Helmut)
Date: 1998/07/02
Raw View
I am porting some old C++ code that compiled well under VMS and Solaris
to aCC on HPUX.
aCC gives the indicated error messages;
the -Dhpux branch works well.

Since I assume that aCC is right
(and that the old code is not ISO C++ conform),
some changes to ISO C++ are not clear to me:

1) Error 641:
 Why is the base class variable "i"
 not in scope in the derived class?
 What other "i" could I mean instead of "this->i"?

2) Error 625:
 Essentially the same as Error 641,
 but it occurs only when B::h is actually instantiated.
 Is there some deeper reason that
 variables are checked always,
 member functions, however, only when
 instantiated?

3) Error 600, Error 643:
 What is the new way to say that only
 some particular template member function should be
 a friend (and not the whole class)?


Helmut Zeisel



The code is as follows:

template<class T> class A
{
public:
  void f(const T& t);
  void g() {};
  int i;
};

template<class T> class B: public A<T>
{
public:
  void fct(const B<T>& rhs)
  {
#ifdef hpux
    this->i = rhs.i;
#else
    i = rhs.i;
    //
    // Error 641: # Undeclared variable 'i'.
    // Did you forget to make the variable dependent on the
    // template type parameters so it would be looked up
    // when templates are generated?
    //
#endif
  }
  void h()
  {
#ifdef hpux
    this->g();
#else
    g();
    // Error 625: # "void A<int>::g()" does not depend
    // upon the template parameters of "void B<int>::h()".
#endif
  }
};

template<class T> class C
{
#ifdef hpux
  friend class A<T>;
#else
  friend void A<T>::f(const T& t);
  //
  // Error 600: # Type specifier is omitted; "int" is no longer assumed.
  // Error 643: # Template type parameter 'T' may not be redeclared
  //     within the scope of the template.
  //
#endif
};

void f()
{
  B<int> b;
  b.h();
}
---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]