VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
16.4 - Multiple Inheritance and DtReaderWriter

While we normally avoid the use of multiple inheritance, several of the basic readable, writable types provided with VR-Forces (such as DtRwString) were created from existing classes by inheriting both DtReaderWriter and the existing class (DtString, for example, in the case of DtRwString).

Remember that if you cast an object constructed using multiple inheritance to a void * (for example, for inclusion on a VR-Link DtList) you must cast back to the original constructed type, not one of its ancestors. For example, the following will compile, but the result is undefined:

DtRwString * createString = new DtRwString("Test String");
void * tempVoid = createString;
...
DtString * useString = (DtString *) tempVoid;
printf (useString->string());

For correct results, replace the last two lines with:

DtRwString * useString = (DtRwString *) tempVoid;
printf (useString->String());

[<< Reading Data from a File] [Home] [Top of Page] [The Reader Writer Registry >>]


Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)