《ObjectARX实用指南——AutoCAD二次开发》第14章协议扩展问题
class AdskEntTemperature : public AcRxObject <BR>{<BR>public:<BR> ACRX_DECLARE_MEMBERS( AsdkEntTemperature );virtual double reflectedEnergy( AcDbEntity * ) const = 0;<BR>};
ACRX_NO_DEFINE_MEMBERS( AsdkEntTemperature, AcRxObject);
//////////////////////////////////////
class AdskDefaultTemperature : public AdskEntTemperature<BR>{<BR>public:<BR>virtual double reflectedEnergy(AcDbEntity * pEnt) const;
}
double AdskDefaultTemperature::reflectedEnergy(AcDbEntity * pEnt) const<BR>{<BR> acutPrintf("\nThis entity has no aarea, and no reflection.\n");<BR> return -1.0;
}
//////////////////////////////////////<BR>class AdskRegionTemperature : public AdskEntTemperature<BR>{<BR>public:<BR>virtual double reflectedEnergy(AcDbEntity * pEnt) const;
}
double AdskRegionTemperature::reflectedEnergy(AcDbEntity * pEnt) const<BR>{<BR> AcDbRegion * pRegion = AcDbRegion::cast( pTnt );<BR> if ( pRegion == NULL )<BR> acutPrintf("\nThis impossible has happened!\n");
double retVal;<BR> if (pRegion->getArea( retVal ) != Acad::eOK )<BR> return -1.0;<BR> return retVal*42.0;
}
//////////////////////////////////////<BR>class AdskCircleTemperature : public AdskEntTemperature<BR>{<BR>public:<BR>virtual double reflectedEnergy(AcDbEntity * pEnt) const;
}
double AdskCircleTemperature::reflectedEnergy(AcDbEntity * pEnt) const<BR>{<BR> AcDbCircle * pCircle = AcDbCircle::cast( pTnt );<BR> if ( pCircle == NULL )<BR> acutPrintf("\nThis impossible has happened!\n");
return pCircle->radius()*6.21*42.0;
}
<BR>void energy()<BR>{<BR> AcDbEntity *pEnt;<BR> AcDbObjectId pEntId;
ads_name en;<BR> ads_point pt;<BR> if ( acedEntSel("\nSelect an Entity:", en, pt) != RTNORM )<BR> {<BR> acutPrintf("Nothing Selected\n");<BR> return;<BR> }
acdbGetObjectId( pEntId, en );<BR> acdbOpenObject( pEnt, pEntId, Acdb::kForRead );
double eTemp = ACRX_X_CALL( pEnt, AsdkEntTemperature ) ->reflectedEnergy( pEnt );<BR> acutPrintf("\nEnergy == %f \n", eTemp );<BR> pEnt->close();<BR>}<BR>
为什么我在入口函数文件头中一定义上述头文件,就会出错:
d:\autocad二次开发\cascoacds\adskenttemperature.h(8) : error C2143: syntax error : missing ';' before '*'<BR>d:\autocad二次开发\cascoacds\adskenttemperature.h(8) : error C2501: 'cast' : missing storage-class or type specifiers<BR>d:\autocad二次开发\cascoacds\adskenttemperature.h(8) : warning C4183: 'cast': member function definition looks like a ctor, but name does not match enclosing class<BR>d:\autocad二次开发\cascoacds\adskenttemperature.h(13) : error C2065: 'AsdkEntTemperature' : undeclared identifier<BR>d:\autocad二次开发\cascoacds\adskenttemperature.h(13) : error C2275: 'AcRxObject' : illegal use of this type as an expression<BR> c:\objectarx2002\inc\rxobject.h(33) : see declaration of 'AcRxObject'<BR>d:\autocad二次开发\cascoacds\adskenttemperature.h(13) : error C2501: 'ACRX_NO_DEFINE_MEMBERS' : missing storage-class or type specifiers<BR>d:\autocad二次开发\cascoacds\adskenttemperature.h(13) : error C2078: too many initializers
应该是什么地方的设置不对,请做过的各位前辈指点。先谢谢你们了。
页:
[1]