What you will learn in this chapter:
wrox.com code downloads for this chapter
You can find the wrox.com code downloads for this chapter at www.wrox.com/remtitle.cgi?isbn=9781118336922 on the Download Code tab. The code in the Chapter10 folder is individually named according to the names throughout the chapter.
Chapter 9 was an introduction about designing your own classes. That chapter ended by designing and writing a simple class named clsDates that added two methods: getLeapYear () and getEaster(). This chapter continues the theme of class design but discusses additional details about writing classes.
When you finish this chapter, you will have a solid foundation upon which to start writing your own classes. With a little effort, you'll find that writing your own classes is both worthwhile and kind of fun.
You should think of constructors as methods designed to create, or instantiate, an object. The sole purpose of a constructor is to enable you to instantiate an object with a known state. The beauty of C# (and most other OOP languages) is that you get a default constructor automatically.
To make the creation of a default constructor possible, a constructor always has the same name as its class. For example, if you want to create an object ...