Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link
added 16 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Is this nested class design ineffective for my Nested Deck class? design and implementation

Previous review of this project:Deck and Card classes and member-accessing with one header

Deck and Card classes and member-accessing with one header

I'm nearly finished with my deck of cards project, and this time I made changes to hide the CardCard class by nesting it in the DeckDeck class. I'm still getting correct results when displaying the deck. However, I do now realize that I can no longer maintain CardCard objects outside the class. Instead, I have to call Card deal() with a DeckDeck object in order to retrieve a CardCard, and I cannot store that CardCard anywhere.

Does this render my design ineffective for this purpose? If so, how else can I maintain CardsCards outside the class while still preventing the user from directly constructing a CardCard? Would a privateprivate constructor (with CardCard un-nested from DeckDeck) be a better option?

Is this nested class design ineffective for my Deck class?

Previous review of this project:Deck and Card classes and member-accessing with one header

I'm nearly finished with my deck of cards project, and this time I made changes to hide the Card class by nesting it in the Deck class. I'm still getting correct results when displaying the deck. However, I do now realize that I can no longer maintain Card objects outside the class. Instead, I have to call Card deal() with a Deck object in order to retrieve a Card, and I cannot store that Card anywhere.

Does this render my design ineffective for this purpose? If so, how else can I maintain Cards outside the class while still preventing the user from directly constructing a Card? Would a private constructor (with Card un-nested from Deck) be a better option?

Nested Deck class design and implementation

Previous review of this project:

Deck and Card classes and member-accessing with one header

I'm nearly finished with my deck of cards project, and this time I made changes to hide the Card class by nesting it in the Deck class. I'm still getting correct results when displaying the deck. However, I do now realize that I can no longer maintain Card objects outside the class. Instead, I have to call Card deal() with a Deck object in order to retrieve a Card, and I cannot store that Card anywhere.

Does this render my design ineffective for this purpose? If so, how else can I maintain Cards outside the class while still preventing the user from directly constructing a Card? Would a private constructor (with Card un-nested from Deck) be a better option?

edited tags
Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
Tweeted twitter.com/#!/StackCodeReview/status/346403935210315776
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /