How do I convert an int to a string?

So I am making a program that prints 5 random cards. I am using a class and I need to set an int between 1 and 4 to a suit in ascending order. Where should I change it, and how can I make it be a string instead of an int?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  class Card {
      private:
              int number, suit;
      public:
             Card () {
                  number = 1;
                  suit = 1;
                  };
             Card (int N, int S) {
                  number = N;
                  suit = S;
                  };
             void setCard(int N, int S){
                  number = N;
                  suit = S;
                  };
             int getNumber () {
                  return number;
                  };
             string getSuit () {
                  return suit;
                  };
             void printCard(){
                  //the conversion should go here?        
                  cout << getNumber() << " of " << getSuit() << endl;
                  };
};
You could always make an array of strings with the suit names already in them.

const string suits[] = {"Clubs", "Diamonds", "Hearts", "Spades"}
I haven't learned how to do that yet. My instructor wants me to do it this way.
Wow building Classes and using strings but not string arrays, but the limitation is what the Instructor set so...

If it was me I would make getSuit() do the work, it already returns a string so pass in the "int suit" to it and let figure it out.

1
2
3
4
5
6
7
8
9
string getSuit(int num){

     string str;
     if//Code here
     else if...

     return str;

}
That's it! Thank you so much for your help!
Topic archived. No new replies allowed.