String does not name a type

Hello, I think this is a fairly easy solution but I'm just missing something. I'm getting an error in my header file that says:
1
2
   12:3 error: 'string' does not name a type
   13:3 error: 'string' does not name a type

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef HEADER_H
#define HEADER_H

using namespace std;

class StudPoker{
	
public:
	
	void deckFunction();
	struct card{
		string rank;
		string suit;
		int value;
		
	} card;
	
	};

    #endif // HEADER_H 

Here is the functions.cpp, my main is empty right now.
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
28
29
30
31
32
33
34
#include "card_games.h"
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

card StudPoker::deckFuncion () {
	
         srand(time(0));

	 struct card deck[52];  // An array of cards named deck, size 52
	

	const string ranks[ ] = { "Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight",
        "Nine", "Ten", "Jack", "Queen", "King" };
		
	const string suits[ ] = { "Diamonds", "Hearts", "Spades", "Clubs" };

	int k = 0; 

	for ( int i = 0; i < 13; i++)
	{
		for ( int j = 0; j < 4; j++)
		{
			deck[ k ].rank = ranks[ i ];
			deck[ k ].suit = suits[ j ];
			k++;
		}
	}
	return (card);
	
    };
	

I'm trying to get this to work so I can use the values in the struct, so any suggestions on improvements would be greatly appreciated. I need to use the random card to send to a player function.
Thanks for the help.
Last edited on
#include <string>
Put that in your header file.
Okay, thanks that fixed one problem. Last thing is, it says that 'card' does not name a type on line 8 of my functions.cpp file. This is my struct. How can I fix this?

Thanks!
deckFunction is a member of StudPoker, not card. Just remove card from line 8 altogether.
Thanks guys! This helped fixed the errors.
Topic archived. No new replies allowed.