Card class problems


hey guys, im trying to make a card class for a poker game.
and im getting a few errors in in the card.cpp
so if anyone can help me out here it would be appreciated
card.h
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
#ifndef CARD_H
#define CARD_H

#include <iostream>
#include <string>
#include <vector>

using namespace std;

class CARD 
{
public:
	CARD();
	
	enum SUIT { SPADES, HEARTS, DIAMONDS, CLUBS };
	enum RANK { ACE = 1, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING };
	enum COLOR { RED, BLACK };
	
	CARD(RANK,SUIT);
	
	int get_rank() const; // returns card rank
	string get_suit() const; // returns suit
	string get_color() const; // returns card color
//	bool cards_dealt(); const; // deal 2 cards per player
private:
	SUIT suit;
	RANK rank;
	COLOR color;
	
	
	
};

#endif 



card.cpp

1
2
3
4
5
6
7
8
#include "Card.h"


CARD::CARD(int r, string s)
{
    RANK = r;
    SUIT = s;
}


these are the errors im getting

Error 1 error C2511: 'CARD::CARD(int,std::string)' : overloaded member function not found in 'CARD' c:\users\x d y n a s 7 y\desktop\afternoon\poker heroz\poker heroz\card.cpp 5
The constructor in a header takes a RANK and a SUIT:

CARD(RANK,SUIT);

The constructor in your cpp file takes an int and a string:
CARD::CARD(int r, string s)

ints and strings are not RANKs and SUITs, so your cpp file doesn't make any sense.

Also...

1
2
3
4
{
    RANK = r;
    SUIT = s;
}


RANK is a type, not a variable. You can't assign a value to a type. That's like saying int = 6; It doesn't make any sense.

You probably meant to assign 'rank' and 'suit' (lowercase -- those are your variables).
Topic archived. No new replies allowed.