The version number can be stored as a data member of the class, and can be filed in and out as the first data member for each object. Because this data is persistent, and is the first item read, it can be checked to determine the version of the object before any other data is read.
When a number is used to differentiate versions of an object, the parent ObjectARX application must be able to handle these two cases of incompatible versions of objects:
Object versioning with a data-member version number is illustrated in the following code fragments from \samples\entity\polysamp\poly.cpp in the ObjectARX SDK.
// Object Version #define VERSION 1 ... Acad::ErrorStatus AsdkPoly::dwgInFields(AcDbDwgFiler* filer) { ... // Object Version - must always be the first item Adesk::Int16 version; filer->readItem(&version); if (version > VERSION) return Acad::eMakeMeProxy; ... } Acad::ErrorStatus AsdkPoly::dwgOutFields(AcDbDwgFiler* filer) const { ... // Object Version - must always be the first item Adesk::Int16 version = VERSION; filer->writeItem(version); ... } Acad::ErrorStatus AsdkPoly::dxfInFields(AcDbDxfFiler* filer) { ... // Object Version case AcDb::kDxfInt16: Adesk::Int16 version; version = rb.resval.rint; if (version > VERSION) return Acad::eMakeMeProxy; break; ... } Acad::ErrorStatus AsdkPoly::dxfOutFields(AcDbDxfFiler* filer) const { ... // Object Version Adesk::Int16 version = VERSION; filer->writeItem(AcDb::kDxfInt16, version); ... }