Hi I need help please I have function called bool earlier that is supposed to return true if the birthday for the invoking Student object is earlier than  the birthday of the parameter object, false otherwise.  I have the function prototype as:  bool earlier(const Student&) const;  and the function body is:  bool Student::earlier(const Student& d) const { d = birthday_; if(d.b < d)   return true;  else if(d.b_>d)   return false;        if(d.bd)   return false;     if(d.b

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Hi I need help please I have function called bool earlier that is supposed to return true if the birthday for the invoking Student object is earlier than 
the birthday of the parameter object, false otherwise. 

I have the function prototype as:  bool earlier(const Student&) const; 

and the function body is: 

bool Student::earlier(const Student& d) const {
d = birthday_;
if(d.b < d)
  return true;
 else if(d.b_>d)
  return false;
     
 if(d.b<d)
  return true;
 else if(d.b>d)
  return false;
  
 if(d.b<d)
  return true;

 }

It is giving me errors shown in the picture. Please help even an explanation will help thank you so much

Student.h x +
1 #ifndef STUDENT_H
2 #define STUDENT_H
3
4 #include <iostream>
5 #include <string>
6 #include "Date.h"
7
8
9 class Student {
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 #endif
using namespace std;
};
protected:
static unsigned nextID;
const unsigned ID_;
string pronouns__;
Date birthday_;
protected:
string name_;
public:
Student ();
Student (const string& n, const string& p, const string& b);
//accessor
bool earlier (const Student&) const;
string given_name() const;
M
friend ostream& operator<<(ostream&, const Student&);
> Console x
>sh -c make -s
./Student.cpp:32:3: error: no viable overloaded '='
d = birthday_;
t'
Shell X +
NNNNNNNNN
./Student.h:9:7: note: candidate function (the implicit c
opy assignment operator) not viable: 'this' argument has
type 'const Student', but method is not marked const
class Student {
./Student.cpp:33:6: error: no member named 'b' in 'Studen
t'
if(d.b < d)
./Student.cpp:35:12: error: no member named 'b_' in 'Stud
ent'
else if(d.b_>d)
./Student.cpp:38:7: error: no member named 'b' in 'Studen
if(d.b<d)
./Student.cpp: 40:12: error: no member named 'b' in 'Stude
t'
nt'
else if(d.b>d)
./Student.cpp:43:7: error: no member named 'b' in 'Studen
if(d.b<d)
6 errors generated.
make: *** [Makefile:9: main] Error 1
exit status 2
Transcribed Image Text:Student.h x + 1 #ifndef STUDENT_H 2 #define STUDENT_H 3 4 #include <iostream> 5 #include <string> 6 #include "Date.h" 7 8 9 class Student { 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #endif using namespace std; }; protected: static unsigned nextID; const unsigned ID_; string pronouns__; Date birthday_; protected: string name_; public: Student (); Student (const string& n, const string& p, const string& b); //accessor bool earlier (const Student&) const; string given_name() const; M friend ostream& operator<<(ostream&, const Student&); > Console x >sh -c make -s ./Student.cpp:32:3: error: no viable overloaded '=' d = birthday_; t' Shell X + NNNNNNNNN ./Student.h:9:7: note: candidate function (the implicit c opy assignment operator) not viable: 'this' argument has type 'const Student', but method is not marked const class Student { ./Student.cpp:33:6: error: no member named 'b' in 'Studen t' if(d.b < d) ./Student.cpp:35:12: error: no member named 'b_' in 'Stud ent' else if(d.b_>d) ./Student.cpp:38:7: error: no member named 'b' in 'Studen if(d.b<d) ./Student.cpp: 40:12: error: no member named 'b' in 'Stude t' nt' else if(d.b>d) ./Student.cpp:43:7: error: no member named 'b' in 'Studen if(d.b<d) 6 errors generated. make: *** [Makefile:9: main] Error 1 exit status 2
C+ Student.cpp x +
8 using namespace std;
9
10
11
12
13
14
15
16▼ Student::Student (const string &n, const string& p, const string& b) : ID_() {
name = n;
17
18
19
20
21
22
23
24
25 string Student::given_name() const {
26
27
28 return first_name;
29 }
30
31 bool Student::earlier(const Student& d) const {
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
unsigned Student:: nextID =
pronouns = p;
birthday_
= b;
nextID++;
cout << endl << n << " was born on << b<< endl;
cout << "Student ID #:" << nextID << endl << "Pronouns: << p << endl;
}
string first_name = name_.substr(0, );
cout << first_name;
d birthday_;
if(d.b < d)
}
return true;
else if(d.b>d)
return false;
1000;
if(d.b<d)
return true;
else if(d.b>d)
return false;
if(d.b<d)
return true;
140
:
Transcribed Image Text:C+ Student.cpp x + 8 using namespace std; 9 10 11 12 13 14 15 16▼ Student::Student (const string &n, const string& p, const string& b) : ID_() { name = n; 17 18 19 20 21 22 23 24 25 string Student::given_name() const { 26 27 28 return first_name; 29 } 30 31 bool Student::earlier(const Student& d) const { 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 unsigned Student:: nextID = pronouns = p; birthday_ = b; nextID++; cout << endl << n << " was born on << b<< endl; cout << "Student ID #:" << nextID << endl << "Pronouns: << p << endl; } string first_name = name_.substr(0, ); cout << first_name; d birthday_; if(d.b < d) } return true; else if(d.b>d) return false; 1000; if(d.b<d) return true; else if(d.b>d) return false; if(d.b<d) return true; 140 :
Expert Solution
Step 1

The error is coming due to no member present with name b_ in the class.

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education