how to get total in c++
//main #include "header.h" int main() { person obj; obj.get(); obj.display(); grades o; o.getG(); o.displayG(); score s; s.getM(); s.tot(); s.displayM(); return 0; } //header.h #include <iostream> using namespace std; const int subjects = 5; class person { private : int age; string name; public: person(){ age=0; name="n"; } ~person(){ } void get(); void display(); }; class grades { private: int grade; public: grades(){ grade =0; } void getG(); void displayG(); }; class score { private: int marks; int total; public: public: score(){ marks =0; total = 0; } void getM(); void tot(); void displayM(); }; //imp.cpp #include "header.h" void person::display() { cout<<"Name is "<<name<<endl; cout<<"Age is "<<age<<endl; } void person:: get() { cout<<"Enter the name "<<endl; cin>>name; cout<<"Enter the age "<<endl; cin>>age; } void grades::displayG() { cout<<"The Grade is "<<grade<<endl; } void grades:: getG() { cout<<"Enter the Grade "<<endl; cin>>grade; } void score::displayM() { cout<<"The score is "<<total<<endl; } void score:: getM() { for (int i; i<= subjects;i++) cout<<"Enter the score of the subject "<<i<<endl; cin>>marks; } void score :: tot() { total = total +marks; } I'm struggling at getting the for statement at void score:: getM() to work if anyone can help me it would be great;