Hello everyone.I'm practising STL and i runned into some
problems.What i want to do is a deck of cards and so i defined
a class with a deque as a private member.Here is my code:
#include <iostream>
#include <deque>
#include <iterator>
usingnamespace std;
class Deck
{
private:
deque <int> myInts(5);
public:
myClass();
int topCard();
};
Deck :: Deck()
{
int j = 54;
deque <int> :: iterator i;
for (i = myInts.begin(); i < myInts.end(); ++i)
{
myInts.insert(i, j++);
}
}
int Deck :: topCard()
{
myInts.pop_back();
return myInts.back();
}
int main()
{
Deck myDeck;
for(int i = 0; i < 5; i++)
{
cout << myDeck.topCard() << endl;
}
system("pause");
return 1;
}
this is what i get from the compiler:
9 C:\Users\denis-john\Documents\c-c++ programs\nothing1.cpp expected identifier before numeric constant
20 C:\Users\denis-john\Documents\c-c++ programs\nothing1.cpp insufficient contextual information to determine type
C:\Users\denis-john\Documents\c-c++ programs\nothing1.cpp In member function `int myClass::topCard()':
28 C:\Users\denis-john\Documents\c-c++ programs\nothing1.cpp insufficient contextual information to determine type