Quantcast
Viewing latest article 21
Browse Latest Browse All 40

Answer by Zan Lynx for C++: expected ';' at end of member declaration

Here is how your code should look. clang-format fixed it up.

#include <iostream>#include <string>using namespace std;class employee {protected:  string name;  string surname;  int tel;  int nbureau;public:  employee(string n, string s, int t, int b) {    name = n;    surname = s;    tel = t;    nbureau = b;  }  void affich() {    cout << "nom" << name << "\nprenom" << surname << "\nnumero tel" << tel<< "\nnumero bureau" << nbureau;  }};class monthly : public employee {private:  double salary;  int nbc;  double tcom;public:  monthly(string n, string s, int t, int b, double sl, int nc,          double tc)::employee(n, s, t, b) {    salary = sl;    nbc = nc;    tcom = tc;  }  void affich() {    cout << "nom" << employee.name << "\nprenom" << employee.surname<< "\nnumero tel" << employee.tel << "\nnumero bureau"<< employee.nbureau << "\nsalaire" << salary<< "\nnombre de commissions" << nbc << "\ntaux de commission" << tc;  }  double salary() { return salary + (nbc * tcom); }};

And this is a version with the syntax fixed up:

#include <iostream>#include <string>using namespace std;class employee {protected:  string name;  string surname;  int tel;  int nbureau;public:  employee(string n, string s, int t, int b)      : name(n), surname(s), tel(t), nbureau(b) {}  void affich() {    cout << "nom" << name << "\nprenom" << surname << "\nnumero tel" << tel<< "\nnumero bureau" << nbureau;  }};class monthly : public employee {private:  double salary;  int nbc;  double tcom;public:  monthly(string n, string s, int t, int b, double sl, int nc, double tc)      : employee(n, s, t, b), salary(sl), nbc(nc), tcom(tc) {}  void affich() {    cout << "nom" << name << "\nprenom" << surname << "\nnumero tel" << tel<< "\nnumero bureau" << nbureau << "\nsalaire" << salary<< "\nnombre de commissions" << nbc << "\ntaux de commission" << tcom;  }  double get_salary() { return salary + (nbc * tcom); }};

Viewing latest article 21
Browse Latest Browse All 40

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>