Foxocsj
@Foxocsj
учусь htmlf

Как исправить ошибку с вводом данных в класс?

У меня есть программа, в которую нужно ввести данные о студенте и вывести их через класс. Вывод я сделал и ввод тоже, но при компиляции выводит ошибку. Как исправить ?

#include <iostream>
#include <math.h>
#include <string>
using namespace std;

class Student {
	string surname;
	string name;
	string patronymic;
	
	public:
	int informatics;
	int algorithmization;
	int algorithm;
	
	float sum() {
		return float(informatics+algorithmization+algorithm)/3;
	}
	
	void vvod() {
		cout << "Введите Фамилию студента: ";
		cin >> surname;
		cout << "\nВведите Имя студента: ";
		cin >> name;
		cout << "\nВведите Отчество студента: ";
		cin >> patronymic;
		cout << "\nВведите оценку по информатике: ";
		cin >> informatics;
		cout << "\nВведите оценку по алгоритмизации: ";
		cin >> algorithmization;
		cout << "\nВведите оценка по теории алгоритмам: ";
		cin >> algorithm;
	}
	
	float max() {
		if (informatics > algorithmization && informatics > algorithm) {
			return informatics;
		}
		if (algorithmization > informatics && algorithmization > algorithm) {
			return algorithmization;
		}
		if (algorithm > algorithmization && algorithm > informatics) {
			return algorithm;
		}
		return algorithm;
	}
	
	void maxSpisok() {
		if (informatics >= algorithmization && informatics >= algorithm) {
			cout << "\n По информатике";
		}
		if (algorithmization >= informatics && algorithmization >= algorithm) {
			cout << "\n По алгоритмизации";
		}
		if (algorithm >= algorithmization && algorithm >= informatics) {
			cout << "\n По теории алгоритмов";
		}
	}
	
	void spisok() {
		bool p = false;
		if (informatics < max()) {
			cout << "\nОценка по информатики ниже средней: " << informatics;
			p = true;
		};
		if (algorithmization < max()) {
			cout << "\nОценка по алгоритмизации ниже средней: " << algorithmization;
			p = true;
		};
		if (algorithm < max()) {
			cout << "\nОценка по теории алгоритмов ниже средней: " << algorithm;
			p = true;
		};
		if (p == false) {
			cout << "\n\tОценок ниже средней нету!";
		};
	}
	
	float vyvod() {
		cout << "Информация о студенте";
		cout << "\nФамилия: " << surname;
		cout << "\nИмя: " << name;
		cout << "\nОтчество: " << patronymic;
		cout << "\nОценка по информатике: " << informatics;
		cout << "\nОценка по алгоритмизации: " << algorithmization;
		cout << "\nОценка по теории алгоритмов: " << algorithm;
		cout << fixed;
		cout.precision(2);
		cout << "\nСредний бал всех оценок: " << sum();
		cout << fixed;
		cout.precision(0);
		return 0;
	};
					
	Student(string surname_n, string name_n, string patronymic_n, int informatics_n, int algorithmization_n, int algorithm_n) {
		surname = surname_n;
        name = name_n;
        patronymic = patronymic_n;
        informatics = informatics_n;
        algorithmization = algorithmization_n;
        algorithm = algorithm_n;
	};
	Student() {};
	~Student() {};
	string getSurname() {return surname;}
    string getName() {return name;}
    string getPatronymic() {return patronymic;}
    void setSurname(string surname_n) { surname = surname_n; }
    void setName(string name_n) { name = name_n; }
    void setPatronymic(string patronymic_n) { patronymic = patronymic_n; }
};
//s1("Корегин", "Александр", "Алексеевич",5,3,2);
int main() {
	Student s1();
	s1.vvod();
	s1.vyvod();
	cout << "\nОценки ниже средней: "; 
	s1.spisok();
	cout << "\nНаибольшая оценка: " << s1.max();
	s1.maxSpisok();
	return 0;
}
  • Вопрос задан
  • 93 просмотра
Решения вопроса 1
@pfemidi
Тут могло бы быть краткое описание меня
В строке

Student s1();

скобки убери:

Student s1;

А вообще подумай о дальнейшем занятии программированием, не твоё это, ой не твоё!
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы