Topic: type qualification necessary?
Author: sbnaran@fermi.ceg.uiuc.edu (Siemel Naran)
Date: 1998/10/21 Raw View
In the argument list of a member func defined out of line, do we
have to qualify the typedefs with their full names? Eg,
template <class T>
struct X
{
typedef T value_type;
value_type func(value_type, value_type);
};
template <class T>
typename X<T>::value_type // return type
X<T>::func
(value_type lhs, value_type rhs) // argument types
{
return lhs+rhs;
}
Or should the "argument types" line above be:
(typename X<T>::value_type lhs, typename X<T>::value_type rhs) // argument types
--
----------------------------------
Siemel B. Naran (sbnaran@uiuc.edu)
----------------------------------
---
[ 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: ncm@nospam.cantrip.org (Nathan Myers)
Date: 1998/10/21 Raw View
Siemel Naran<sbnaran@KILL.uiuc.edu> wrote:
>In the argument list of a member func defined out of line, do we
>have to qualify the typedefs with their full names? Eg,
>template <class T>
>struct X
>{
> typedef T value_type;
> value_type func(value_type, value_type);
>};
>template <class T>
>typename X<T>::value_type // return type
>X<T>::func
> (value_type lhs, value_type rhs) // argument types
> { return lhs+rhs; }
>Or should the "argument types" line above be:
>(typename X<T>::value_type lhs, typename X<T>::value_type rhs)
The argument list is in the scope of the class the function
is a member of, so you don't need to qualify argument type
names that mention member types.
--
Nathan Myers
ncm@nospam.cantrip.org http://www.cantrip.org/
[ 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 ]