- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hey there,
I'm trying to create a class that inherits from two other classes. Both these two MFC classes also inherit from a common type:
class c1 : public CWnd { ... };
class c2 : public CWnd { ... };
class c3 : public c1, public c2 { ... DECLARE_DYNCREATE(c3) ... };
...
IMPLEMENT_DYNCREATE(c3, c1) // error C2594: 'return' : ambiguous conversions from 'c3 *' to 'CObject *'
IMPLEMENT_DYNCREATE(c3, CWnd) // ALSO error C2594: 'return' : ambiguous conversions from 'c3 *' to 'CObject *'
I looked over IMPLEMENT_DYNCREATE() but couldn't understand what it meant or how to fix it.
I will try experimenting with different ways to fix this in the mean time.
Thanks in advance for any help.
-Steve
I'm trying to create a class that inherits from two other classes. Both these two MFC classes also inherit from a common type:
class c1 : public CWnd { ... };
class c2 : public CWnd { ... };
class c3 : public c1, public c2 { ... DECLARE_DYNCREATE(c3) ... };
...
IMPLEMENT_DYNCREATE(c3, c1) // error C2594: 'return' : ambiguous conversions from 'c3 *' to 'CObject *'
IMPLEMENT_DYNCREATE(c3, CWnd) // ALSO error C2594: 'return' : ambiguous conversions from 'c3 *' to 'CObject *'
I looked over IMPLEMENT_DYNCREATE() but couldn't understand what it meant or how to fix it.
I will try experimenting with different ways to fix this in the mean time.
Thanks in advance for any help.
-Steve
링크가 복사됨
2 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Fixed.
Replace IMPLEMENT_DYNCREATE with IMPLEMENT_DYNCREATE_REINTERPRET and define the following:
#define IMPLEMENT_DYNCREATE_REINTERPRET(class_name, base_class_name) \
CObject* PASCAL class_name::CreateObject() \
{ return reinterpret_cast(new class_name); } \
IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, \
class_name::CreateObject, NULL)
I feel kind of dumb that the solution seems to be this simple. At least someone else can benefit from this potentially.
Thanks anyway!
-Steve
Replace IMPLEMENT_DYNCREATE with IMPLEMENT_DYNCREATE_REINTERPRET and define the following:
#define IMPLEMENT_DYNCREATE_REINTERPRET(class_name, base_class_name) \
CObject* PASCAL class_name::CreateObject() \
{ return reinterpret_cast
IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, \
class_name::CreateObject, NULL)
I feel kind of dumb that the solution seems to be this simple. At least someone else can benefit from this potentially.
Thanks anyway!
-Steve
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
It worked! But I had to modify to:
#define IMPLEMENT_DYNCREATE_REINTERPRET(class_name, base_class_name) \
CObject* PASCAL class_name::CreateObject() \
{ return reinterpret_cast<base_class_name*>(new class_name); } \
IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, \
class_name::CreateObject, NULL)