Re: Private Constructor

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Morten Wennevik (MortenWennevik_at_hotmail.com)
Date: 03/05/04


Date: Fri, 05 Mar 2004 11:58:30 +0100

A private constructor will prevent anyone (outside the class) from
instantiating that class

Car c = new Car(name, type, ID); // won't work outside the class
Car c = new Car(); // won't exist, since you have another constructor

if you add

public static Car Nissan
{
        get
        {
                return new Car("Nissan", type, ID);
        }
}

to get Car c = Car.Nissan; to work;

Happy coding!
Morten

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/