Can there be another implementation of this program, without empty constructor? Can someone write it ?  #include #include using namespace std; //class lecturer class lecturer{     //data members     string name;     string department;          public:          //empty constructor     lecturer(){              }          //constructor     lecturer(string n, string d){         name = n;         department = d;     }          //setter for name     void set_name(string n){         name = n;     }          //setter for department     void set_dep(string d){         department = d;     }          //getter for name     string get_name(){         return name;     }          //getter for department     string get_dep(){         return department;     }          string toString(){         string des = "Name :" + get_name() + " Department: " + get_dep();         return des;     } }; //class lecture class Lecture{     //data members     private:     string subject;     string weekday;     int hour;     bool online;     lecturer l;          public:          //empty constructor     Lecture(){              }          //constructor     Lecture(string sub, string w, int h, bool o, lecturer le){         subject = sub;         weekday = w;         hour = h;         online = o;                  l.set_name(le.get_name());         l.set_dep(le.get_dep());     }          //setter for subject     void set_sub(string sub){         subject = sub;     }          //setter for weekday     void set_weekd(string w){         weekday = w;     }          //setter for hour     void set_hour(int h){         hour = h;     }          //setter for online     void set_on(bool on){         online = on;     }          //setter for lecturer     void set_lec(lecturer le){         l.set_name(le.get_name());         l.set_dep(le.get_dep());     }               //getter for subject     string get_sub(){         return subject;     }          //getter for weekday     string get_weekd(){         return weekday;     }          //getter for hour     int get_hour(){         return hour;     }          //getter for online     bool get_on(){         return online;     }          //function to check whether the lecture starts at 7-11     bool isItMorning(){         if (hour >=7 && hour <=11)         return true;                  else         return false;     }          //function to display description     string toString(){         string des = l.toString() + " Subject : " + subject + " Day: " + weekday          + " Time : " + to_string(hour) + " Online: " + to_string(online);         return des;     }      }; int main(){          //objects of lecturer     lecturer l1("xyz", "CS");     lecturer l2("abc", "maths");          //calling toString function     cout<

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

Can there be another implementation of this program, without empty constructor? Can someone write it ? 

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

//class lecturer
class lecturer{
    //data members
    string name;
    string department;
    
    public:
    
    //empty constructor
    lecturer(){
        
    }
    
    //constructor
    lecturer(string n, string d){
        name = n;
        department = d;
    }
    
    //setter for name
    void set_name(string n){
        name = n;
    }
    
    //setter for department
    void set_dep(string d){
        department = d;
    }
    
    //getter for name
    string get_name(){
        return name;
    }
    
    //getter for department
    string get_dep(){
        return department;
    }
    
    string toString(){
        string des = "Name :" + get_name() + " Department: " + get_dep();
        return des;
    }
};

//class lecture
class Lecture{
    //data members
    private:
    string subject;
    string weekday;
    int hour;
    bool online;
    lecturer l;
    
    public:
    
    //empty constructor
    Lecture(){
        
    }
    
    //constructor
    Lecture(string sub, string w, int h, bool o, lecturer le){
        subject = sub;
        weekday = w;
        hour = h;
        online = o;
        
        l.set_name(le.get_name());
        l.set_dep(le.get_dep());
    }
    
    //setter for subject
    void set_sub(string sub){
        subject = sub;
    }
    
    //setter for weekday
    void set_weekd(string w){
        weekday = w;
    }
    
    //setter for hour
    void set_hour(int h){
        hour = h;
    }
    
    //setter for online
    void set_on(bool on){
        online = on;
    }
    
    //setter for lecturer
    void set_lec(lecturer le){
        l.set_name(le.get_name());
        l.set_dep(le.get_dep());
    }
    
    
    //getter for subject
    string get_sub(){
        return subject;
    }
    
    //getter for weekday
    string get_weekd(){
        return weekday;
    }
    
    //getter for hour
    int get_hour(){
        return hour;
    }
    
    //getter for online
    bool get_on(){
        return online;
    }
    
    //function to check whether the lecture starts at 7-11
    bool isItMorning(){
        if (hour >=7 && hour <=11)
        return true;
        
        else
        return false;
    }
    
    //function to display description
    string toString(){
        string des = l.toString() + " Subject : " + subject + " Day: " + weekday 
        + " Time : " + to_string(hour) + " Online: " + to_string(online);
        return des;
    }
    
};

int main(){
    
    //objects of lecturer
    lecturer l1("xyz", "CS");
    lecturer l2("abc", "maths");
    
    //calling toString function
    cout<<l1.toString()<<endl;
    cout<<l2.toString()<<endl;
    
    //array of Lecture objects
    Lecture L[5];
    
    //initialising the array 
    L[0] = Lecture("Java","Monday",8,true,l1);
    L[1] = Lecture("C++","Tuesday",9,false,l1);
    L[2] = Lecture("DS","Monday",10,true,l1);
    L[3] = Lecture("Calculus","Monday",7,true,l2);
    L[4] = Lecture("Geometry","Wednesday",8,false,l2);
    
    cout<<endl;
    
    //ofstream object
    ofstream out;
    
    //open output file
    out.open("detail.txt");
    
    //printing the details to the screen and the output file
    for(int i=0;i<5;i++)
    {
    cout<<L[i].toString()<<endl;
    out<<L[i].toString()<<endl;
    }
    
    //close output file
    out.close();
    
    return 0;
}




Expert Solution
Step 1

C++ Empty creator necessity depends upon category style necessities. we all know that C++ category creator is termed after we produce AN object of a category.

If a category isn't needed to initialize its knowledge member or doesn't contain knowledge member, there's no ought to write empty creator expressly. On category object creation, default creator implicitly known as are enough.

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