Hello, I am having trouble with this code in c++ for my advance data structure course . I am using the onlinegdb.com complier and get this small issue. I have provided both the snip of the result as well as the code. main.cpp #include #include"Student.h" #include #include "Student.h" #include "Faculty.h" using namespace std; int main() {    Student std("John","Smith",3.75,"Spring 2019");    Faculty faculty("Mary","Smith","2019");    cout<<"===========================================\n";    faculty.Print();    cout<<"===========================================\n";    cout<<"\n\n\n";    cout<<"===========================================\n";    std.Print();    cout<<"===========================================\n";    return 0; } Person.h ifndef PERSON_H #define PERSON_H #include #include using namespace std; class Person { private:    int personID;    string firstName;    string lastName; public:    Person(string fName, string lName);    string getFirstName();    string getLastName();    int getID();    virtual void Print() = 0;    static int nextID; }; #endif Person.cpp #include #include "Person.h" using namespace std; int Person::nextID = 0; Person::Person(string fName, string lName){    nextID=nextID+1;    personID=nextID;    this->firstName=fName;    this->lastName=lName; } string Person::getFirstName(){    return firstName; } string Person::getLastName(){    return lastName; } int Person::getID(){    return personID; } Student.h #ifndef STUDENT_H #define STUDENT_H #include #include #include "Person.h" using namespace std; class Student : public Person { private:    float gpa;    string admissionTerm; public:    Student(string fName, string lName, float gpa, string adTerm);    bool setGPA(float gpa);    float getGPA();    string getAdmissionTerm();    void Print(); }; #endif  Student.cpp #include #include #include "Student.h" #include using namespace std; Student::Student(string fName, string lName, float gpa, string adTerm): Person(fName, lName){    setGPA(gpa);    admissionTerm=adTerm; } bool Student::setGPA(float gpa){    if(gpa<0 || gpa>4){        gpa=0;        return false;    }    else        this->gpa=gpa; } float Student::getGPA(){    return gpa; } string Student::getAdmissionTerm(){    return admissionTerm; } void Student::Print(){    cout< #include #include "Person.h" using namespace std; class Faculty : public Person{ private:    string year; public:    Faculty(string fName, string lName,string year);    string getYear();    void Print(); }; #endif  Faculty.cpp #include #include #include"Faculty.h" #include using namespace std; Faculty::Faculty(string fName, string lName, string year) : Person(fName, lName){    this->year=year; } string Faculty::getYear(){    return year; } void Faculty::Print(){    cout<

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Hello, I am having trouble with this code in c++ for my advance data structure course . I am using the onlinegdb.com complier and get this small issue. I have provided both the snip of the result as well as the code.

main.cpp

#include<iostream>
#include"Student.h"
#include<iostream>
#include "Student.h"
#include "Faculty.h"
using namespace std;

int main()
{
   Student std("John","Smith",3.75,"Spring 2019");
   Faculty faculty("Mary","Smith","2019");


   cout<<"===========================================\n";
   faculty.Print();
   cout<<"===========================================\n";
   cout<<"\n\n\n";
   cout<<"===========================================\n";
   std.Print();
   cout<<"===========================================\n";
   return 0;
}

Person.h

ifndef PERSON_H
#define PERSON_H
#include<iostream>
#include<string>
using namespace std;
class Person
{
private:
   int personID;
   string firstName;
   string lastName;
public:
   Person(string fName, string lName);
   string getFirstName();
   string getLastName();
   int getID();
   virtual void Print() = 0;
   static int nextID;
};

#endif

Person.cpp

#include<iostream>
#include "Person.h"
using namespace std;
int Person::nextID = 0;
Person::Person(string fName, string lName){
   nextID=nextID+1;
   personID=nextID;
   this->firstName=fName;
   this->lastName=lName;
}
string Person::getFirstName(){
   return firstName;
}
string Person::getLastName(){
   return lastName;
}
int Person::getID(){
   return personID;
}

Student.h

#ifndef STUDENT_H
#define STUDENT_H
#include<iostream>
#include<string>
#include "Person.h"
using namespace std;
class Student : public Person
{
private:
   float gpa;
   string admissionTerm;
public:
   Student(string fName, string lName, float gpa, string adTerm);
   bool setGPA(float gpa);
   float getGPA();
   string getAdmissionTerm();
   void Print();

};

#endif 

Student.cpp

#include<iostream>
#include<iomanip>
#include "Student.h"
#include<string>
using namespace std;
Student::Student(string fName, string lName, float gpa, string adTerm): Person(fName, lName){
   setGPA(gpa);
   admissionTerm=adTerm;
}
bool Student::setGPA(float gpa){
   if(gpa<0 || gpa>4){
       gpa=0;
       return false;
   }
   else
       this->gpa=gpa;
}
float Student::getGPA(){
   return gpa;
}
string Student::getAdmissionTerm(){
   return admissionTerm;
}

void Student::Print(){
   cout<<fixed<<setprecision(2);
   cout<<left<<setw(20)<<"Student First Name "
                   <<":"<<setw(20)<<getFirstName()<<endl;
   cout<<left<<setw(20)<<"Student Last Name "
                   <<":"<<setw(20)<<getLastName()<<endl;
   cout<<left<<setw(20)<<"Student ID "
                   <<":"<<setw(20)<<getID()<<endl;
   cout<<left<<setw(20)<<"Student GPA "
                   <<":"<<setw(20)<<getGPA()<<endl;
   cout<<left<<setw(20)<<"Student Admit Term "
                   <<":"<<setw(20)<<getAdmissionTerm()<<endl;
}

Faculty.h

#ifndef FACULTY_H
#define FACULTY_H
#include<iostream>
#include<string>
#include "Person.h"
using namespace std;
class Faculty : public Person{
private:
   string year;
public:
   Faculty(string fName, string lName,string year);
   string getYear();
   void Print();
};

#endif 

Faculty.cpp

#include<iostream>
#include<iomanip>
#include"Faculty.h"
#include<string>
using namespace std;
Faculty::Faculty(string fName, string lName, string year) : Person(fName, lName){
   this->year=year;
}
string Faculty::getYear(){
   return year;
}
void Faculty::Print(){
   cout<<fixed<<setprecision(2);
   cout<<left<<setw(20)<<"Faculty First Name "
                   <<":"<<setw(20)<<getFirstName()<<endl;
   cout<<left<<setw(20)<<"Faculty Last Name "
                   <<":"<<setw(20)<<getLastName()<<endl;
   cout<<left<<setw(20)<<"Faculty ID "
                   <<":"<<setw(20)<<getID()<<endl;
   cout<<left<<setw(20)<<"Faculty Hire Year "
                   <<":"<<setw(20)<<getYear()<<endl;
}

Student.cpp:17:1: warning: control reaches end of non-void function [-Wreturn-type]
17 | }
|
Faculty First Name
Faculty Last Name
Faculty ID
Faculty Hire Year
:Mary
:Smith
:2
:2019
=====
====== =====
====
=====
====== ================ =========== ==========
Student First Name
:John
Student Last Name
:Smith
Student ID
:1
Student GPA
:3.75
Student Admit Term
:Spring 2019
====== ================ ========
==== ====
...Program finished with exit code 0
Press ENTER to exit console. |
Transcribed Image Text:Student.cpp:17:1: warning: control reaches end of non-void function [-Wreturn-type] 17 | } | Faculty First Name Faculty Last Name Faculty ID Faculty Hire Year :Mary :Smith :2 :2019 ===== ====== ===== ==== ===== ====== ================ =========== ========== Student First Name :John Student Last Name :Smith Student ID :1 Student GPA :3.75 Student Admit Term :Spring 2019 ====== ================ ======== ==== ==== ...Program finished with exit code 0 Press ENTER to exit console. |
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY