Article ID: 143352
Article Last Modified on 7/5/2005
/* Compile options needed: None
*/
//#define _WORKAROUND //uncomment this line to work around
template<class T>
class classA
{
public:
classA(T& t) : m_t(t) {}
protected:
T m_t;
};
template<class T>
class classB
{
public:
classB(const T& t) : m_t(t) {}
#ifndef _WORKAROUND
operator classA<T>();
#else
operator classA<T>() { return classA<T>(m_t); }
#endif
protected:
T m_t;
};
#ifndef _WORKAROUND
// Error C2988 for the following function definition.
template<class T>
classB<T>::operator classA<T>()
{
return classA<T>(m_t);
}
#endif
void main()
{
classB<int> b(2);
// Invoke template<class T> classB<T>::operator classA<T>()
classA<int> a = b;
}
Additional query words: kbVC400bug inline
Keywords: kbbug kbfix kbvc500fix kbcpponly kbcompiler KB143352