- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page