- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- 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)