error C2440
-
Hi. I am having this error and I don't know what to do with it.. Please help. error C2440: 'initializing' : cannot convert from 'class CDocument *' to 'class CVector_3DDoc *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast When I double clicked on the error, it points to this code: CCVector_3DDoc* pDoc = GetDocument(); What is wrong with this code? class CVector_3DDoc is a class that I have added with the base class as CDocument. Thanks.
-
Hi. I am having this error and I don't know what to do with it.. Please help. error C2440: 'initializing' : cannot convert from 'class CDocument *' to 'class CVector_3DDoc *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast When I double clicked on the error, it points to this code: CCVector_3DDoc* pDoc = GetDocument(); What is wrong with this code? class CVector_3DDoc is a class that I have added with the base class as CDocument. Thanks.
ReturnRain wrote:
What is wrong with this code?
The compiler is telling you exactly what is wrong.
CCVector_3DDoc* pDoc = (CCVector_3DDoc *) GetDocument();
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
ReturnRain wrote:
What is wrong with this code?
The compiler is telling you exactly what is wrong.
CCVector_3DDoc* pDoc = (CCVector_3DDoc *) GetDocument();
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Hi. Thank for replying. But now I have another error: error C2440: 'type cast' : cannot convert from 'class CDocument *' to 'class CVector_3DDoc' No constructor could take the source type, or constructor overload resolution was ambiguous What does it mean? :confused:
-
Hi. I am having this error and I don't know what to do with it.. Please help. error C2440: 'initializing' : cannot convert from 'class CDocument *' to 'class CVector_3DDoc *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast When I double clicked on the error, it points to this code: CCVector_3DDoc* pDoc = GetDocument(); What is wrong with this code? class CVector_3DDoc is a class that I have added with the base class as CDocument. Thanks.
-
Try this ya CCVector_3DDoc* pDoc =reinterpret_cast(GetDocument()); VIBIN "Fool's run away,where angle's fear to tread"
-
Hi. Thank for replying. But now I have another error: error C2440: 'type cast' : cannot convert from 'class CDocument *' to 'class CVector_3DDoc' No constructor could take the source type, or constructor overload resolution was ambiguous What does it mean? :confused:
ReturnRain wrote:
...to 'class CVector_3DDoc'
The cast operation is wrong. You should be casting one pointer to another.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Please tell me CCVector_3DDoc is derived from CDocument before you go and use reinterpret_cast everywhere to fix everything :)
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder