Article ID: 148688
Article Last Modified on 7/5/2005
/* Compile options needed: None
*/
#include <iostream.h>
template<class T>
class Base;
template<class T>
ostream& operator<<(ostream& s, const Base<T> & a)
{
return s;
}
template<class T>
class Base
{
public:
friend ostream& operator<<(ostream& s, const Base<T>& a);
};
class Derived;
ostream& operator<<(ostream& s, const Derived& a)
{
return s;
}
// Replace 'private' by 'public' in the following line
// to avoid the error (work around # 2)
class Derived : private Base<char> {
public:
friend ostream& operator<<(ostream& s, const Derived& a);
};
void main(void)
{
Derived objDerived;
// The C2243 error is generated for the following line.
// Uncomment the typecast to avoid the error (work around # 1)
cout << /*(const Derived&)*/ objDerived;
}
Additional query words: kbVC400bug
Keywords: kbbug kbfix kblangcpp kbvc500fix kbcpponly kbcompiler KB148688