Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Student {
- private:
- string name, surname;
- int age;
- float average;
- public:
- Student () {
- cout << "empty constructor" << endl;
- }
- Student(string _name, string _surname, int _age, float _average) {
- name = _name;
- surname = _surname;
- age = _age;
- average = _average;
- }
- Student(const Student & tmp) {
- name = tmp.name;
- surname = tmp.surname;
- age = tmp.age;
- average = tmp.average;
- }
- // getters
- string get_name() {
- return name;
- }
- string get_surname() {
- return surname;
- }
- int get_age() {
- return age;
- }
- float get_average() {
- return average;
- }
- //setters
- void set_name(string _name) {
- name = _name;
- }
- void set_surname(string _surname) {
- surname = _surname;
- }
- void set_age(int _age) {
- age = _age;
- }
- void set_average(float _average) {
- average = _average;
- }
- void print() {
- cout << name << " " << surname << " " << age << " " << average << endl;
- }
- };
- int main()
- {
- Student s("Petar", "Petrovski", 23, 9.5);
- cout << s.get_name() << " " << s.get_age() << endl;
- s.set_name("Petat");
- cout << s.get_name() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement