Introduction to OOP | Chapter 5: Messages Instances and Initialization: | next | previous | audio | real | text |
class PlayingCard { public: PlayingCard ( ) // default constructor, // used when no arguments are given { suit = Diamond; rank = 1; faceUp = true; } PlayingCard (Suit is) // constructor with one argument { suit = is; rank = 1; faceUp = true; } PlayingCard (Suit is, int ir) // constructor with two arguments { suit = is; rank = ir; faceUp = true; } }; PlayingCard *cardOne = new PlayingCard(); PlayingCard *cardTwo = new PlayingCard(Heart); PlayingCard *cardThree = new PlayingCard(Diamond, 7);