Click here to Skip to main content
15,914,401 members
Please Sign up or sign in to vote.
4.50/5 (6 votes)
See more:
Why is CObject the base class for the majority of MFC classes?
Posted
Updated 13-Jul-10 6:17am
v2

From CObject Class (MFC)[^] on MSDN:

CObject provides basic services, including:
- Serialization support
- Run-time class information
- Object diagnostic output
- Compatibility with collection classes

...it could be venerated :)
 
Share this answer
 
v2
What difference does it make *-why* CObject is the ultimate base class. It simply is, and there's nothing you can do about it.
 
Share this answer
 
Simple answer - it's not.

The answer to "why did Microsoft think it was a good idea in MFC to derive (almost) everything from CObject?" is probably that they thought it was a good idea at the time.

Back in 1991 the C++ implementation they had to play with was a pretty unsophisticated C++ compiler (no templates, namespaces and exceptions) and some of the features of CObject were really to overcome the lack of features and lack of experience of using C++. This includes things like dynamic creation and base class pointer collection classes.

Cheers,

Ash
 
Share this answer
 
v2
Comments
Nish Nishant 13-Jul-10 12:16pm    
Reason for my vote of 5
Adds useful info to CPallini's answer. 5!
What is the point of your question?
Are you asking about the usefulness of a single rooted classes hierarchy?
Are you asking if CObject fits well as MFC root class?
Or are you worried about "CObject" as root class name?
:)
 
Share this answer
 
Comments
Nish Nishant 13-Jul-10 12:15pm    
Reason for my vote of 5
Good answer, and worth a 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900