BUG: 'using' Declaration Doesn't Overload Base Class Members

Last reviewed: July 24, 1997
Article ID: Q140604
The information in this article applies to:
  • The Microsoft C/C++ Compiler (CL.EXE) included with: - Microsoft Visual C++, 32-bit Edition, versions 4.0, 4.1, 4.2, 5.0

SYMPTOMS

Attempting to overload member functions located in a base class from a derived class with a 'using' declaration, may result in the following compiler error:

   error C2664: 'function': cannot convert parameter 'number' from
   'type1' to 'type2'

CAUSE

This particular problem occurs if the member functions that are being overloaded are declared before the 'using' declaration in the class definition.

RESOLUTION

Place the 'using' declaration above the declarations for the member functions you want to overload. See the comments in the following code sample:

Sample Code

   #include "iostream.h"

   class A
   {
   public:
      int f(int) {cout << "In A::f(int)!!!\n";return 0;}
   };

   class B : public A
   {
   public:
      int f(char*){cout << "In D::f(char*)!!!\n";return 0;}
      using A::f;        // <<== move this above the int f(char*)
                         //  declaration to fix the problem.
   };

   void main()
   {
      B d;
      d.A::f(1);
      d.f(1);            // <<== C2664 happens here
      d.f("Hi There");
   }

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

REFERENCES

For more information on the 'using' declaration, please drill down to the following topic in the Visual C++ Online Help:

   \Visual C++ Books\C/C++\C++ Language\Reference\Declarations\
   Namespaces\using Declaration
 

	
	


Keywords : CLIss vcbuglist400 vcbuglist500
Version : 4.0 4.1 4.2 5.0
Platform : NT WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.