Primary-expression error

It shows error "expected primary-expression before ',' token" on line 10.
I ran out of ideas how to fix it.....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  #include <string>
using namespace std;
class Students{
    string name;
    string surname;
    int age;
    int No;
public:
        Students():
        Students(string, string, int, int);
        void setName(string);
        void SetSurname (string);
        void setAge (int);
        void setNo(int);
        string getName();
        string getSurname();
        int getAge();
        int getNo();

};
Last edited on
Line 9: Replace the ':' with ';'
Watch your punctuation on line 9!
Students():
That colon should be ... a semicolon.
Also when passing string to a function, you'd usually pass as const string& to avoid a pass-by-value copy (unless you're using move semantics later). age and No should be default initialised so that the default constructor doesn't have to.

Topic archived. No new replies allowed.