I'm having some issues with a rather new concept to me.
I have a class that is giving me errors which I'm not quite understanding.
They are
Build started: Project: mp7, Configuration: Debug Win32 ------
1> code.cpp
1>c:\users\jordan\documents\visual studio 2010\projects\lad\lad\cards.h(42): warning C4832: token '.' is illegal after UDT 'cards'
1> c:\users\jordan\documents\visual studio 2010\projects\lad\lad\cards.h(10) : see declaration of 'cards'
1>c:\users\jordan\documents\visual studio 2010\projects\lad\lad\cards.h(42): error C2275: 'cards' : illegal use of this type as an expression
1>c:\users\jordan\documents\visual studio 2010\projects\lad\lad\cards.h(42): error C2228: left of '.face' must have class/struct/union
1>c:\users\jordan\documents\visual studio 2010\projects\lad\lad\cards.h(43): warning C4832: token '.' is illegal after UDT 'cards'
1> c:\users\jordan\documents\visual studio 2010\projects\lad\lad\cards.h(10) : see declaration of 'cards'
1>c:\users\jordan\documents\visual studio 2010\projects\lad\lad\cards.h(43): error C2275: 'cards' : illegal use of this type as an expression
1>c:\users\jordan\documents\visual studio 2010\projects\lad\lad\cards.h(43): error C2228: left of '.suit' must have class/struct/union
1>c:\users\jordan\documents\visual studio 2010\projects\lad\lad\cards.h(45): error C2143: syntax error : missing ';' before '.'
1>c:\users\jordan\documents\visual studio 2010\projects\lad\lad\cards.h(45): error C2143: syntax error : missing ';' before '.'
1>c:\users\jordan\documents\visual studio 2010\projects\lad\lad\cards.h(46): error C2143: syntax error : missing ';' before '.'
1>c:\users\jordan\documents\visual studio 2010\projects\lad\lad\cards.h(46): error C2143: syntax error : missing ';' before '.'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This is where they are coming from;
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <iomanip>
using namespace std;
class cards
{
private:
int face;
char suit;
public:
cards(int = 0, char = ' ');
void display();
void swap(cards&);
void setCards(int, char);
//Getters
int getFace();
char getSuit();
};
//Functions
cards::cards(int f, char s)
{
face = f;
suit = s;
}
void cards::swap(cards& c)
{
cards temp;
temp.face = c.face;
temp.suit = c.suit;
c.face = cards.face;
c.suit = cards.suit;
cards.face = temp.face;
cards.suit = temp.suit;
}
void cards::display()
{
switch(face)
{
case 11: cout <<"J" << endl;
break;
case 12: cout << "Q" << endl;
break;
case 13: cout << "K" << endl;
break;
case 1: cout << "A" << endl;
default: cout << face;
}
cout << suit;
}
void cards::setCards(int f, char s)
{
face = f;
suit = s;
}
int cards::getFace()
{
return face;
}
char cards::getSuit()
{
return suit;
}
|
missing ';' before '.'
When I looked this up the error c2143 it said missing token 1 before token 2. I'm not sure how to interpret this.
Any help please and thank you with understand standing these issues?