Visual C++Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
something in CObject puzzle me such as:
concept: serialization,dump context,assert validity,and the meaning for creation of the class
anybody help me, i need a biiiggg help
to make clear these concept
I can program quite many inherited classes of CObject with fluency,but even today,after about half a year since I study C++, I don't know the meaning of CObject
To understand CObject you will have to go a bit deeper.
If your know COM, you know that you can call a piece of software COM component if it implements IUnknown and exposes a few standard initialization methods. IUnknown serves as a contract that the software writer fulfills and in the process implements some basic functionality in his software that lets it run properly by any other piece of software that uses it as COM component.
COM components that are ActiveX controls fulfill another set of contract in the form of IDispatch.
All of this is there so that the user of the piece of software could be sure that a certain basic functionally is present.
Now, since IUnkown is implemented in almost the same way always there are classes that implement IUnknown for you --all you have to do is to inherit your class from there helper classes. There are many such classes that are there to provide you some âBasicâ functionality on which you can build your more specific code. CObject serves the same purpose. Since every MFC class is inherited from CObject you can be sure that every MFC class has a set of âbasic functionalityâ built into it. These functionalities include serialization, compatibility with collection classes etc you can check the help for the complete list. What does this mean? well it means that if you want to make a class in which you want the CArchive based serialization implemented all you need to do is inherit your class from CObject and write a couple of functions with minimal code.
Also the fact that all the MFC classes are derived from CObject you can use it for purposes like making a base class pointer that can point to any MFC class etc.
C# has an Object class and java has an object class for pretty much the same purpose.