# Include <iostream> <br/> # include <vector> <br/> using namespace STD; </P> <p> Enum suit <br/> {<br/> spade = 0, <br/> heart, <br/> diamond, <br/> club <br/>}; </P> <p> class poker <br/>{< br/> PRIVATE: <br/> suit m_suit; <br/> int m_number; <br/> Public: <br/> poker (suit, int number) <br/>{< br/> m_suit = suit; <br/> m_number = number; <br/>}</P> <p> string getsuit () <br/>{< br/> string suit = "spade "; <Br/> If (m_suit = heart) <br/> suit =" heart "; <br/> If (m_suit = diamond) <br/> suit = "diamond"; <br/> If (m_suit = Club) <br/> suit = "club"; <br/> return suit; <br/>}</P> <p> friend ostream & operator <(ostream & OS, poker * PK) <br/>{< br/> string suit = PK-> getsuit (); <br/> OS <"[" <suit. c_str () <":" <PK-> m_number <"]"; <br/> return OS; <br/>}< br/> }; </P> <p> class cards <br/> {<B R/> PRIVATE: <br/> vector <poker *> m_cards; <br/> Public: <br/> cards () <br/> {<br/> for (INT I = 0; I <52; I ++) <br/>{< br/> m_cards.push_back (new poker (suit) (I/13), (I % 13) + 1 )); <br/>}< br/> void output () <br/>{< br/> vector <poker *> :: iterator iter = m_cards.begin (); <br/> for (; iter! = M_cards.end (); ITER ++) <br/>{< br/> cout <(poker *) (* ITER) <Endl; <br/>}< br/>}; </P> <p> int _ tmain (INT argc, _ tchar * argv []) <br/>{< br/> cards * cards = new cards (); <br/> cards-> output (); <br/> int A = 0; <br/> A = cin. get (); <br/> return 0; <br/>}
When I was reading the forum, I saw someone asking me how to make the licensing more oo.
I made a simple oo playing card...
Using poker objects to represent each card has two attributes: Color and number.
Then pack it with cards.