i am unable to fix the error 'expected primary exp before public in my program

how do i fix the errors expected primary expression before public and also expected '}'before else error pls help

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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
      # include<iostream>
    #include<fstream>
    #include<sstream>
    using namespace std;
    template <class A>
    class Array
    {

        int siz;
        public:
            A *a;
        void create_array(int cap)
        {
           if(cap>0)
           {
            a=new A[cap];
            siz=cap;
           }
           else
           {
               cout<<"the size is wrong";
           }
        }
        void store(A values,int index)
        {
            if(index<siz&&index>=0)
            a[index]=values;
            else
                cout<<"invalid index";
        }
        A retrieve(int index)
        {
            if(index<siz&&index>=0)
            return a[index];
            else
                cout<<"inavalid index";
        }

    };
    template <class S>
    class stacks
    {
        Array <S>obj;
        int top;
        int capacity;
        public:
            stacks()
            {
                top=0;
                capacity=0;
            }
       void create_stack(int s)
       {
            capacity=s;
            top=0;
            obj.create_array(s);
       }
       void push(S value)
       {
           if(!isFull())
           {
               obj.store(value,top);
               top+=1;
           }
           else
            cout<<"stack overflow";
       }
        S pop()
        {
            if(top!=0)
               {
                   top-=1;
                return obj.retrieve(top);
               }
            else
                cout<<"stack underflow";
        }
       bool isFull()
        {
            if(top==capacity)
                return true;
            else
                return false;
        }

        bool isEmpty()
        {
            if(top==0)
                return true;
            else
                return false;
        }
    };
    template<class Q>
    class queues
    {
        int cap;
        int head,tail;
        Array<Q>obj;
       void create_queue(int size)
       {
        if(size>0)
        {
            cap=size;
            obj.create_array(size);
            head=0;
            tail=0;
       }
       else
        cout<<"invalid size"<<endl;
       }
        bool isEmpty()
        {
            if(head==0&&tail==0)
                return true;
            return false;
        }
        bool isFull()
        {
            if(tail==cap)
                return true;
            return false;
        }
        void enqueue(Q value)
       {
           if(head==0&&!isFull())
           {
               obj.store(value,tail);
               tail+=1;
           }
           else if(!isFull())
           {
               int i;
               while(head!=0)
               {
                   for(i=head;i<tail;i++)
                    obj.a[i-1]=obj.a[i];
                   head-=1;
                   tail-=1;
               }
               obj.store(value,tail);
               tail+=1;
           }
           else
            cout<<"queue full"<<'\n';

       }
        Q dequeue()
        {
           if(!isEmpty())
            {
                Q val=obj.retrieve(head);
                head+=1;
                return val;
            }
            else
            {
                cout<<"queue empty"<<'\n';
            }
        }
    };
    //template<class T>
    class fileinp
    {
       public:
     void readme()
       {
           ifstream inf("input.txt");
       string strinput;
       string adt;
       int value;
       while(!inf.eof())
       {
           inf>>strinput;
           if(strinput.compare("stack")==0)
                   {
                    adt="stack";
                      inf>>strinput;
                   // public:
                      if(strinput.compare("int")==0)
                       {
                        stacks<int> obj1;
                       }
                      else
                        if(strinput.compare("float")==0)
                        {
                           stacks <float> obj1;
                        }
                      else
                        if(strinput.compare("double")==0)
                           {
                                stacks <double> obj1;
                           }
                        else
                          if(strinput.compare("char")==0)
                            {
                               stacks<char> obj1;
                            }
                        else
                           {
                             stacks<int> obj1;
                           }
                   }

           else
           {
               if(strinput.compare("queue")==0)
                   {
                      adt="queue";
                      inf>>strinput;
                     public:
                      if(strinput.compare("int")==0)
                       {
                         queues<int> obj1;
                       }
                      else if(strinput.compare("float")==0)
                        {
                           queues<float> obj1;
                        }
                      else if(strinput.compare("double")==0)
                       {
                           queues<double> obj1;
                       }
                        else if(strinput.compare("char")==0)
                        {
                         queues<char> obj1;
                        }
                        else
                           {
                               queues<int> obj1;
                           }
                   }
            }
        };
                    while(!inf.eof())
                   {
                           inf>>strinput;
                        if(adt.compare("stack")==0&&strinput.compare("push")==0)
                               {
                                  inf>>strinput;
                                 istringstream (strinput) >> value;
                                  obj1.push(value);
                               }
                       else if(adt.compare("stack")==0&&strinput.compare("pop")==0)
                               {
                                  cout<<"the value popped is"<<obj1.pop();
                               }
                        else if(adt.compare("queue")==0&&strinput.compare("enqueue")==0)
                                {
                                  inf>>strinput;
                                  istringstream(strinput) >> value;
                                  obj1.enqueue(value);
                                }
                        else if(adt.compare("queue")==0&&strinput.compare("dequeue")==0)
                                {
                                  cout<<"the value dequeued is"<<obj1.dequeue();
                                }
                         else
                                inf>>strinput;

                   }


       }
    };
    int main()
    {
        int s;
        stacks <int>obj2;
        cin>>s;
        cout<<"size is "<<s<<'\n';
        obj2.create_stack(s);
        obj2.push(10);
        obj2.push(5);
        int k=obj2.pop();
        cout<<k;
       fileinp obj;
       obj.readme();
    return 0;
    };
Put the code you need help with here.
What is "public:" doing on line 211?

Did you bother to look at the line indicated in the error message? Why did you not post the actual error message with the line number in it instead of making us search through 280 lines of code? If you want help, provide all relevant information.
Topic archived. No new replies allowed.