oop tutorials
Saaa
empty at needmail.com
Tue Mar 4 07:13:43 PST 2008
> Two things.
> First, a null reference is free to set up, whereas instantiating a class
> is not free.
But always writing an extra line isn't free and if nobody would use null
references that would be kind of stupid.
^^ thats what I thought (^_^)
>
> 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.
bike would only hold a reference to an Human, right? and you say this is
bad?
Sorry, I read it as having only a reference is bad .. I must read this wrong
:/
More information about the Digitalmars-d-learn
mailing list