oop tutorials

Christopher Wright dhasenan at gmail.com
Tue Mar 4 06:55:29 PST 2008


Saaa wrote:
> Thanks,
> Why isn't it initialized?
> I mean, when are these null referenced class pointers useful?
> 

Two things.
First, a null reference is free to set up, whereas instantiating a class 
is not free.

Second:

---
class Bicycle {
    Human owner;
}

auto bike = new Bicycle();
---

The bike doesn't have an owner. Do you want to create a Human object 
that refers to nobody? Well, maybe, for some purposes, but not 
necessarily. That would probably alter your definition of Human.


More information about the Digitalmars-d-learn mailing list