Re: Private Constructor
From: Morten Wennevik (MortenWennevik_at_hotmail.com)
Date: 03/05/04
- Next message: BuddyWork: "Re: Code Path"
- Previous message: Tristan: "Testing equality of pens"
- In reply to: Q2004: "Private Constructor"
- Next in thread: Morten Wennevik: "Re: Private Constructor"
- Reply: Morten Wennevik: "Re: Private Constructor"
- Messages sorted by: [ date ] [ thread ]
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/
- Next message: BuddyWork: "Re: Code Path"
- Previous message: Tristan: "Testing equality of pens"
- In reply to: Q2004: "Private Constructor"
- Next in thread: Morten Wennevik: "Re: Private Constructor"
- Reply: Morten Wennevik: "Re: Private Constructor"
- Messages sorted by: [ date ] [ thread ]