Odd error

#include <cstdlib>
#include <iostream>
using namespace std;

class Card {
int theSuit, theFace;
public:
int setSuit (int suit);
int setFace (int face);
int getSuit;
int getFace;
};

int Card::setSuit(int suit) {
suit = theSuit;
}

int Card::setFace(int face){
face = theFace;
}

int main()
{
srand(time(0));
int arr [52];
for (int j=0;j<52;j++){
arr[j]=j;
}
Card c;
int eight;
eight = rand() %51 + 1;
if(eight%4==0){
c.setSuit(1);
}
if(eight%4==1){
c.setSuit(2);
}
if(eight%4==2){
c.setSuit(3);
}
if(eight%4==3){
c.setSuit(4);
}
if(eight%13==0){
c.setFace(1);
}
if(eight%13==1){
c.setFace(2);
}
if(eight%13==2){
c.setFace(3);
}
if(eight%13==3){
c.setFace(4);
}
if(eight%13==4){
c.setFace(5);
}
if(eight%13==5){
c.setFace(6);
}
if(eight%13==6){
c.setFace(7);
}
if(eight%13==7){
c.setFace(8);
}
if(eight%13==8){
c.setFace(9);
}
if(eight%13==9){
c.setFace(10);
}
if(eight%13==10){
c.setFace(11);
}
if(eight%13==11){
c.setFace(12);
}
if(eight%13==12){
c.setFace(13);
}

string suitPrnt;
if (c.getSuit = 1){
suitPrnt = "Hearts ";
}
if (c.getSuit = 2){
suitPrnt = "Shovels ";
}
if (c.getSuit = 3){
suitPrnt = "Clovers ";
}
if (c.getSuit = 4){
suitPrnt = "Crooked Squares ";
}
int tehface = c.getFace;

cout<<"N yer hillbilly card is: " << tehface << " of " << suitPrnt;
system("PAUSE");
}









For those running it, it winds up returning a really big negative number instead of the face value. Anyone know where my dumb mistake was?
You need to put this->theFace = face; and the same for the suit I think. As it is your are assigned the temp variable to theFace, which is some random unknown value

EDIT: Lol, wrong order...
Last edited on
Just tried that. Still isn't working.

As it stands now, the variable "eight" returns what it's supposed to. So I screwed it up in the storage and retrieval portion.
Topic archived. No new replies allowed.