0 or 0L for empty pointers?

Allan Sandfeld Jensen kde at carewolf.com
Fri Jun 23 17:15:11 BST 2006


On Friday 23 June 2006 17:36, Lubos Lunak wrote:
>  Yet another own type system? Yes, you are oldfashioned.
>
It's not another type system. It is just common sense. 

Look at KHTML for instance:

Depending on tree, all object either derive from NodeImpl* or RenderObject*, 
and in many places you need to know what objects you are dealing with. When 
you _need_ a specific type of information you add it to your datatype. In 
this way type-information is no different from other types of information. 
This way you can have code that does: 

if (node->isTextnode()) 
	do the appropiate thing. 

Or as a side bonus you can do fast safe casts. 

if (node->isTextNode()) 
	static_cast<TextNodeImpl*>(node)->setText("Hello world!");

Again: type-information is no different from any other type of information, if 
you need it, you add it your objects.

`Allan




More information about the kde-core-devel mailing list