Discussion:
Why is CArchive class not derived from Cobject class in MFC
(too old to reply)
RAGHU
2010-01-20 19:59:32 UTC
Permalink
Hi all,

I am new to MFC

My question is why is CARCHIVE class not derived from COBJECT class

I am not able to find satisfying answer from blogs

Please explain on this

TIA,
RAGHU
Giovanni Dicanio
2010-01-21 09:14:48 UTC
Permalink
[added microsoft.public.vc.mfc]
Post by RAGHU
I am new to MFC
You may want to consider microsoft.public.vc.mfc newsgroup for MFC
questions.
Post by RAGHU
My question is why is CARCHIVE class not derived from COBJECT class
There are several classes in MFC that are not derived from CObject, as you
can read from the following diagram:

http://msdn.microsoft.com/en-us/library/ws8s10w4(VS.80).aspx

Classes like CArchive (or CDumpContext) are kind of "helper classes" for
CObject: they are *used* by CObject for some features like e.g.
serialization (CArchive), or run-time type information (CRuntimeClass), etc.

When you have an hineritance relation, you may think of it as a "Is-A" kind
of relation. So, if CArchive had been derived from CObject, it would have
meant something like "CArchive *Is-A* CObject". But this does not reflect
the nature of CArchive, which is not a CObject, but is just an *helper class
used by* CObject. CArchive is a "tool" that CObject uses to offer some
features (like serialization support).

HTH,
Giovanni

Loading...