c 2b 2b my boolean operator return only 0

Solutions on MaxInterview for c 2b 2b my boolean operator return only 0 by the best coders in the world

showing results for - "c 2b 2b my boolean operator return only 0"
Lola
30 Feb 2017
1#include <iostream>
2#include<string>
3using namespace std;
4
5 class Student{
6  public:
7      string name;
8      string major;
9      double gpa;
10      Student(string aName, string aMajor, double aGpa){
11        name=aName;
12        major=aMajor;
13        aGpa=gpa;
14      }
15      bool hasHonor(){
16        if (aGpa>=3.5)
17            return true;
18        if (aGpa<3.5)
19        return false;
20      }
21};
22int main()
23{
24    Student student1("Jim", "Businnes", 2.4);
25    Student student2("Pam", "Art", 4);
26    cout<<student2.hasHonor()<<endl;
27    cout<<student1.hasHonor();
28    return 0;
29}