几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】ype Cast Error Using Odrx-declare-members (http://www.dimcax.com/hust/showthread.php?t=18852)

yang686526 2009-05-07 05:30 PM

【转帖】ype Cast Error Using Odrx-declare-members
 
type cast error using odrx_declare_members
type cast error using odrx_declare_members
i recently switched to version 1.1.0 from 1.09.
i was hoping someone could tell me if i am correctly using the ocrx_declare_members macro for the following case.
class cicodrenderview : public odrxobjectimpl<odgsbaseview>
{
odrx_declare_members(cicodrenderview);
public:
cicodrenderview();
......
}
with the above, i get:
error c2594: 'type cast' : ambiguous conversions from 'class odrxobject *' to 'class cicodrenderview *
by expanding the macro, i find that the problem occurs in this line:
return odsmartptr<cicodrenderview>(((cicodrenderview*)pob j->queryx(cicodrenderview::desc())), kodrxobjattach);
thanks.
hi,
no, odrx_declare_members macro can't be used in this case. odgsbaseview is derived from multiple rxobject-based classes. you should make additional branch to use rx rtti with cicodrenderview object, however odsmartptr<cicodrenderview> can't be ever created.
code:
class cicodrenderview_rtti : public odrxobject
{
cicodrenderview_rtti() {}
public:
odrx_declare_members(cicodrenderview_rtti);
cicodrenderview* getcicodrenderviewinterface() { return static_cast<cicodrenderview*>(this); }
};
class cicodrenderview : public odgsbaseview, public cicodrenderview_rtti
{
friend class cicodrenderview_rtti;
protected:
cicodrenderview();
public:
......
}
class cicodrenderviewimpl : public odrxobjectimpl<cicodrenderview>
{
public:
cicodrenderviewimpl();
}


所有的时间均为北京时间。 现在的时间是 04:39 PM.