Wrox Programmer Forums
|
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
 
Old August 13th, 2004, 04:49 AM
Authorized User
 
Join Date: Aug 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default CObject problem

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



 
Old August 13th, 2004, 07:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default


What are you trying to do.
 
Old August 16th, 2004, 12:35 AM
Authorized User
 
Join Date: Aug 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old August 16th, 2004, 04:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

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.

Ankur





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 14 - use of CObject problem jabuck BOOK: Ivor Horton's Beginning Visual C++ 2005 0 February 15th, 2007 02:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.