FIX: C2682 Using dynamic_cast to Cast to a Const Pointer Type (150576)
The information in this article applies to:
- Microsoft Visual C++ 4.0
- Microsoft Visual C++ 4.1
- Microsoft Visual C++ 4.2
This article was previously published under Q150576 SYMPTOMS
When casting a const pointer of derived class to a const pointer of base
class, the compiler generates the following error message:
C2682: cannot use dynamic_cast to convert from "'const class 'name1'*
to 'const class 'name2'*'"
where name1 and name2 refer to the names of your derived class and base
class respectively.
RESOLUTION
Cast the derived class const pointer to a derived class non-const pointer.
Then use the derived class non-const pointer in the dynamic_cast
expression. See the MORE INFORMATION section of this article for sample
code and a workaround.
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: | Major | Last Reviewed: | 10/24/2003 |
---|
Keywords: | kbbug kbCompiler kbfix kbVC500fix KB150576 |
---|
|