Help Me! " expected primary expression before public " Cant fix it and need someone to fix it for me.

#include <iostream>
using namespace std;

class schools
{
public:
void stfatima(){
cout << " st fatimai s shiut" << endl;

public:




void stfatimaStudents(int a, int b,){
cout << " Amount of boys in school" << a << endl;
cout << " amount of girls" << b << endl;
int c = a + b;
cout << " amount of all together" << c << endl;
}
}


};

int main ()
{
cout << " hi vergo";



}
Please use [code][/code] tags when posting code.
Also, indentation always makes finding things like this a doddle.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;

class schools {
public:
  void stfatima() {
    cout << " st fatimai s shiut" << endl;
  public:  //!! why are you saying this again?

    //!! C++ doesn't have nested functions, so you need the closing }
    //!! for stfatima before this
    void stfatimaStudents(int a, int b,) {
      cout << " Amount of boys in school" << a << endl;
      cout << " amount of girls" << b << endl;
      int c = a + b;
      cout << " amount of all together" << c << endl;
    }
  }
};

int main()
{
  cout << " hi vergo";
}


so i deleted pbublic and did the close } before void stfatimaStudents and still sayig expected primary expression b4 public
Yeah, describing what you did, and proving what you did by posting your edits are two different things.

Did you save the file before pressing compile?

ye and also it worked now. After I did all you described it made the errors I had lesser and then there was an error left so I looked at my code again and I found out I put a , after int b so thanks bro for ur help
Topic archived. No new replies allowed.