Oops, how do i do code blocks, same as dreamincode
Code:
...
?

Tried making the destructor private, but for some reason that did nothing. Maybe because all objects are seen as base-class Object, and delete is called from there, so it's legit?

Either way, I'm looking for a way for delete to work, even on the singleton, but I guess it doesn't work that way.

I'll post everything, but am running swiftly out of time, so I adapted it to a less cool but almost working version. Still, it's quite an interesting problem (to me at least)

NullObject.h
Code:
#ifndef NULLOBJECT_H
#define NULLOBJECT_H

#include "Object.h"
#include <iostream>

using namespace std;

/**
* An Object that represents 'null'.
*/
class NullObject: public Object // has Singleton been implemented correctly?
{
	private:
		static NullObject* instance;
		static unsigned count;
		
	protected:
		~NullObject() {}
		NullObject() {}
		NullObject(const NullObject&);
		NullObject& operator = (const NullObject&);
		virtual int compareTo(const Object&) const;
	public:

		static NullObject* getInstance()
		{
			if (instance == 0 && count == 0)
				instance = new NullObject();
			count++;
			return instance;
		}
		
		void operator delete (void*);
		
		
		virtual bool isNull() const;
		virtual void print(ostream& = cout) const;
		virtual Object* clone() const;
		virtual Object& assignment (const Object&);
};

#endif
NullObject.C:
Code:
#include "NullObject.h"
#include <typeinfo>

NullObject* NullObject::instance =NULL;
unsigned NullObject::count = 0;

/**
* Checks if 'other' is another NullObject, and then compares accordingly.
*/
int NullObject::compareTo(const Object& other) const
{
	if (typeid (NullObject) == typeid (other))
		return 0;
	else
		throw ("incompatible_type_exception"); // the two types need to be identical
}
		
void NullObject::operator delete (void* p)
{
	if (count != 0)
		count--;

	if (count == 0)
	{
		::operator delete(p);
	}
}

NullObject::NullObject(const NullObject& other)
{
	instance = other.instance;
}

NullObject& NullObject::operator = (const NullObject& other)
{
	instance = other.instance;
	return *instance;
}

bool NullObject::isNull () const
{
	return true;
}

void NullObject::print (ostream& out) const
{
	out << "NullObject" << endl;
}

Object* NullObject::clone () const
{
	return new NullObject();
}

Object& NullObject::assignment (const Object& other)
{
	if (typeid(other) == typeid(NullObject))
	{
		return (*this);
	}
	else
		throw ("incompatible_type_exception");
}