You receive a link error when you build an application that contains a base class in Visual C++ (130486)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Editions 1.0
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 2.1
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++ .NET (2003)
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ 2005 Express Edition
This article was previously published under Q130486 SYMPTOMS When building an application that contains a base class
with a pure virtual operator= function and a class derived from the base class
with a defined operator= function, a following link error is generated for the
base class's operator=: error LNK2001: unresolved
external symbol This also occurs if the classes reside in a DLL and
are declared with the __declspec( dllexport ) storage-class attribute.
In Visual C++ .NET you will receive the following error message:
LNK2019: unresolved external symbol
CAUSE This behavior is by design. The assignment operator is not
inherited. Normal inheritance rules do not apply, and declaring it pure virtual
does not have the usual affect. RESOLUTION Since operator= is not inherited, any declaration of
operator= in the base class is unused and unnecessary. Do not declare the
operator= in the base class.
Modification Type: | Major | Last Reviewed: | 12/9/2005 |
---|
Keywords: | kberrmsg kbtshoot kbCompiler kbCPPonly kbprb KB130486 kbAudDeveloper |
---|
|