How this can work without these empty constructors ? #include using namespace std; class Lecturer { private: string name; string department; public: // empty constructor Lecturer(){ } Lecturer(string n, string d){ name = n; department = d; } string getName(){ return name; } void setName(string n){ name = n; } void setDepartment(string d){ department=d; } string getDepartment(){ return department; } string toString() { cout<=7 && hour <=11) return true; else { return false; } } //function to display description string toString() { return l.toString() +"\n"+ "Subject: "+subject+ "\n"+"Day: "+weekday+ "\n"+ "Time: " + to_string(hour)+"\n"+ "Online: " + to_string(online); } }; int main(){ // object lecturer Lecturer lecturer1("S.Stouchev", "History"); Lecturer lecturer2("Y.Edreva", "Physics"); //calling 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

How this can work without these empty constructors ?

#include<iostream>
using namespace std;

class Lecturer {
private:
string name;
string department;

public:
// empty constructor
Lecturer(){

}



Lecturer(string n, string d){
name = n;
department = d;
}

string getName(){
return name;
}

void setName(string n){
name = n;
}

void setDepartment(string d){
department=d;
}
string getDepartment(){
return department;
}

string toString() {
cout<<endl;
return "Name: " + getName()+" Department: " + getDepartment();
}

};

class Lecture {
private:
string subject;
string weekday;
int hour;
bool online;
Lecturer l;

public:

Lecture(){

}

Lecture(string s, string w,int h, bool onl,Lecturer lec) {
subject=s;
weekday=w;
hour=h;
online=onl;

l.setName(lec.getName());
l.setDepartment(lec.getDepartment());
}

// getter subject, setter subject
string getSubject(){
return subject;
}

void setSubject (string s){
subject=s;
}

// getter weekday, setter weekday
string getWeekday(){
return weekday;
}

void setWeekday(string w){
weekday=w;
}

//getter hour, setter hour
int getHour(){
return hour;
}

void setHour(int h){
hour=h;
}

// getter online, setter online
bool getOnline(){
return online;
}

void setOnline(bool onl){
online = onl;
}

//setter for lecturer
void setLecturer(Lecturer l){
l.setName(l.getName());
l.setDepartment(l.getDepartment());
}

//function to check if the lecture starts at 7-11
bool isItMorning() {
if (hour>=7 && hour <=11)
return true;

else {
return false;
}
}

//function to display description
string toString() {
return l.toString() +"\n"+ "Subject: "+subject+ "\n"+"Day: "+weekday+ "\n"+ "Time: " + to_string(hour)+"\n"+ "Online: " + to_string(online);

}

};


int main(){

// object lecturer

Lecturer lecturer1("S.Stouchev", "History");
Lecturer lecturer2("Y.Edreva", "Physics");

//calling
cout<<lecturer1.toString()<<endl;
cout<<lecturer2.toString()<<endl;

//array of Lecture objects
Lecture Lect[3];

Lect[0] = Lecture("History","Monday",13,true,lecturer1);
Lect[1] = Lecture("Physics","Tuesday",7,false,lecturer2);
Lect[2] = Lecture("Cultural Heritage","Monday",10,false,lecturer1);

cout<<endl;

for(int i=0;i<3;i++) {
cout<<Lect[i].toString()<<endl;
}







}

 

Expert Solution
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
  • SEE MORE 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