problem with STL

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:

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
#include <iostream>
#include <deque>
#include <iterator>
using namespace 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

Line 9: you can't initialize the object at declaration.

Line 11: wrong constructor name

I have no idea what lines 19-22 are trying to do. At best, myInts will be empty at that point
so the loop will run zero times.
Topic archived. No new replies allowed.