Introduction to OOP Chapter 4: Classes and Methods: next previous audio real text


class PlayingCard {
		// constructor, initialize new playing card
	public PlayingCard (Suits is, int ir) 
		{ suit = is; rank = ir; faceUp = true; }


A constructor is a method that is used to initialize a newly constructed object. In C++, Java, C# and many other languages it has the same name as the class. We will talk about constructors more in the next chapter.
Intro OOP, Chapter 4, Slide 18