Как добавить пользовательский ввод при использовании класса в C ++C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Как добавить пользовательский ввод при использовании класса в C ++

Сообщение Anonymous »

Мне трудно вводить пользовательский ввод для имени, основных, терминов и среднего значения. Мне также трудно вносить вклад в 5 курсов. < /p>

Код: Выделить всё

#include 
using namespace std;

class StudentProfile {
private:  //Acess specifier
string name = "";  //private information
string  major = "";  //private information
string term = "";  //private information
double termAverage = 0;

public:  //Acess specifier

StudentProfile(string namen, string majorm, string termn, int terma){

this ->name = namen;
this ->major = majorm;
this ->term = termn;
this ->termAverage = terma;
}

int scores[5]= {85,87,97,86,95};  //Member function

double findAverage(){//Member function
double Average = this ->scores[0] + this ->scores[1] + this ->scores[2] + this ->scores[3] + this ->scores[4];
Average = Average/5;
this ->termAverage = Average;
return Average;
}

void displayProfile(){  //Member Function
cout termAverage;
}
void setScore(int index, int scoreln){
this ->scores[index] = scoreln;
}
};

int main(){

StudentProfile StudentRecord("","","",90);//creates an object of StudentProfile

int courseOne = 80;
StudentRecord.setScore(0, courseOne);

int courseTwo = 70;
StudentRecord.setScore(1, courseTwo);

int courseThree = 70;
StudentRecord.setScore(2, courseThree);

int courseFour = 70;
StudentRecord.setScore(3, courseFour);

int courseFive = 70;
StudentRecord.setScore(4, courseFive);

dProfile.findAverage();

dProfile.displayProfile();

return 0;
}
Я попытался использовать cout

Подробнее здесь: https://stackoverflow.com/questions/795 ... class-in-c
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»