Homework Help

This is my final homework assignment. I've been looking over these errors but I need some help. Is anyone out there?

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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
  #include <iostream>
#include <vector>
#include <string>
using namespace std;

template<class T>
   class mlist
   {
   public:
    mlist();//creates the list
    T front();//returns the front of the list
    T end();//returns the end of the list and moves every entry up one position;
    bool in(T x);//returns true if x is in the list and false otherwise
    bool empty(); // returns true if the list is empty
    void addfront(T entry);//add entry to the back of the list
    void addend(T entry);//add entry to the back of the list
    void addorder(T entry);//add entry to an ordered list
    void removefront();//removes the front of the list
    void removeend();//removes the back of the list
    void remove(T n);//searches the list and removes the entry with value n
    private:
    vector<T> mlist;
    void remove(typename vector<T>::iterator ix, T n);//uses an iterator and recursion to remove value n
    void addorder(typename vector<T>::iterator ix, T n);//uses an iterator and recursion to add value n in an ordered list
    }; // mlist


template <typename T>
mlist<T> :: mlist(){}

template <typename T>
mlist<T> :: front()
{
    return *mlist.begin();
}

template <typename T>
mlist<T> :: end()
{
    return(*--mlist.end());
}

template <typename T>
bool mlist<T> in (Tx)
{
    for(int i = 0; i<mlist.size(); i++)
    {
        if(mlist [i] == x)
        {
            return true;
        }
    }
    return false;
}

bool mlist<T> in (Tx)
{
    typename vector <T> :: iterator it;
    for (it = mlist.begin; it! = mlist.end(); it++)
    {
        if (* it == x)
        {
            return true;
        }
    }
    return false;
}

template <typename T>
bool mlist<T> empty()
{
    if (mlist.size() == 0)
    {
        return true;
    }
    else
    {
        return false;
    }

}

template <typename T>
void mlist<T> addfront (T entry)
{
    mlist.insert (mlist.begin(), entry);
}

template <typename T>
void mlist<T> :: addend (T entry)
{
    mlist.push_back(entry);
}

template <typename T>
void mlist<T> :: remove front()
{
    mlist.erase (mlist.begin());
}

template <typename T>
void mlist<T> :: remove end()
{
    mlist.erase (--mlist.end());
}

template <typename T>
void mlist<T> :: remove (Tn)
{
    remove (mlist.begin(), n);
}

template <typename T>
void mlist<T> :: remove (typename vector <T> :: iterator ix, Tn)
{
    if (ix == mlist.end())
    {
        return;
    }
    if (*ix == n)
    {
        mlist.erase (ix);
        return;
    }
    remove (++ ix, n);
}

template <typename T>
void mlist<T> :: addorder (T entry)
{
    addorder (mlist.begin(), entry)
}
{
    if (ix == mlist.end())
    {
        mlist.insert(ix, n);
        return;
    }
    if (n <= *ix)
    {
        mlist.insert(ix, n);
        return;
    }
    addorder(++ix, n);
}

int main()
{
 mlist<int> test1=mlist<int>() ;
 test1.add(5);
 test1.add(7);
 test1.add(4);
 test1.remove(7);
 cout << test1.front()<< endl;
 cout << test1.back()<< endl;
 mlist<string> test2= mlist<string>() ;
 test2.add("John");
 test2.add("Paul");
 test2.add("Mary");
 test2.add("Kate");
 test2.remove("Paul");
 cout << test2.front()<< endl;
 cout << test2.back()<< endl;
}


|32|error: need 'typename' before 'mlist<T>::T' because 'mlist<T>' is a dependent scope|

|38|error: need 'typename' before 'mlist<T>::T' because 'mlist<T>' is a dependent scope|

|44|error: invalid declarator before 'in'|

|56|error: 'T' was not declared in this scope|

|56|error: template argument 1 is invalid|
1
2
3
4
5
6
7
8
template <typename T>
/*¿return type?*/
mlist<T> :: front()
{
    return *mlist.begin();
}

bool mlist<T> in (Tx) //¿ah? 

Topic archived. No new replies allowed.