Answers for "c++ my boolean operator return only 0"

C++
0

c++ my boolean operator return only 0

#include <iostream>
#include<string>
using namespace std;

 class Student{
  public:
      string name;
      string major;
      double gpa;
      Student(string aName, string aMajor, double aGpa){
        name=aName;
        major=aMajor;
        aGpa=gpa;
      }
      bool hasHonor(){
        if (aGpa>=3.5)
            return true;
        if (aGpa<3.5)
        return false;
      }
};
int main()
{
    Student student1("Jim", "Businnes", 2.4);
    Student student2("Pam", "Art", 4);
    cout<<student2.hasHonor()<<endl;
    cout<<student1.hasHonor();
    return 0;
}
Posted by: Guest on January-29-2021

Browse Popular Code Answers by Language