Error with class functions

When trying to compile my program I get this error:
1
2
In function `void setCardSuit()': 
5 `cardSuit' undeclared (first use this function) 

I get the same error for all 3 variable in all 3 class Card functions.

My include files:
1
2
3
4
5
int intCard = 0;
#include "cardClass.cc"
#include "setCardSuit.cc"
#include "setCardFace.cc"
#include "setCardValue.cc" 



My class code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Card
{
public: 
    void setCardSuit();
    void setCardFace();
    void setCardValue();
    void setCard()
    {
        setCardSuit();
        setCardFace();
        setCardValue();
    }
    void showCard()
    {
        cout << cardFace << (char)cardSuit << "  ";   
    }
    
private:
    int cardSuit;
    char cardFace;
    int cardValue;    
};


My function code:
1
2
3
4
5
6
void setCardSuit()
{
    if (intCard <13)
    {
          cardSuit = 3;   
    }

The code for setCardSuit, setCardFace, and setCardValue functions is about the same.


Please help me find whats missing. If you need more info, or if I gave too much, let me know. Thank you for all the help.
Last edited on
Problem solved!

This is a great site. After reviewing the docs on this site I found what I needed in no time.
http://www.cplusplus.com/doc/tutorial/classes.html

Just needed to add Card::.

Make
1
2
3
4
5
6
void setCardSuit()
{
    if (intCard <13)
    {
          cardSuit = 3;   
    }



Look like
1
2
3
4
5
6
void Card::setCardSuit()
{
    if (intCard <13)
    {
          cardSuit = 3;   
    }



Lookin good. The test program worked! I was able to build a deck of 52 cards and cout them out showing face value and suit. (Needed to gloat over a job well done. No one else is around.)
Last edited on
I would like to go ahead and claim credit for the solution anyway. hehe. :) Merry Christmas. ^_^
Topic archived. No new replies allowed.