FIX: C2243 on Friend Overload o (148688)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
This article was previously published under Q148688 SYMPTOMS
The following error is generated:
error C2243: 'abstract declarator' : conversion from 'class Derived *'
to 'const class Base<Type> &' exists, but is inaccessible
in code that contains all of the following: - A template base class that has a friend function that overloads
operator << for ostream.
- A derived class that privately inherits its base class and has a friend
function that overloads operator << for ostream where the second
argument to the operator << is a reference to const type (const
Derived &).
- A call to the operator << passing a non-const derived type object.
RESOLUTION
Use one of the following two workarounds to resolve the problem: - Typecast the derived object to a reference to const type when using
the operator <<.
-or-
- Make the base class public instead of private.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This bug was corrected in Visual C++
version 5.0.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbbug kbCompiler kbCPPonly kbfix kbLangCPP kbVC500fix KB148688 |
---|
|