We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C++
- Classes
- Classes and Objects
- Discussions
Classes and Objects
Classes and Objects
Sort by
recency
|
425 Discussions
|
Please Login in order to post a comment
This is my code if inputs were lines of string: class Student{ public: vector scores; void input(); int calculateTotalScore(); };
void Student::input(){ string container; cin.ignore(); //delete the first "enter"
} int Student::calculateTotalScore(){ int total =0; for (int i=0; i
Here is my code!
class Student{ private: int scores[5]; public: void input(){ for(int i=0;i<5;i++){ cin>> scores[i]; } } int calculateTotalScore(){ int result = 0; for(int i=0;i<5;i++){ result += scores[i]; } return result; } }; /