fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Student {
  5. public:
  6. string name;
  7. string major;
  8. double gpa;
  9. Student(string aName, string aMajor, double aGpa) {
  10. name = aName;
  11. major = aMajor;
  12. gpa = aGpa;
  13. }
  14.  
  15. bool hasHonors() {
  16. if(gpa >= 3.2) {
  17. return true;
  18. }
  19. return false;
  20. }
  21. };
  22.  
  23. int main() {
  24.  
  25. Student student1("Linh", "Liberature", 3.8);
  26. Student student2("My", "Geography", 3.9);
  27.  
  28. cout << student2.hasHonors();
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
1