Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++, I cannot get the instructor portion to work Here are my codes: Course.h #include using namespace std; #ifndef Course_H #define Course_H class Course

In C++, I cannot get the instructor portion to work

image text in transcribedimage text in transcribedHere are my codes:

Course.h

#include using namespace std;

#ifndef Course_H #define Course_H

class Course { private: long courseNumber; string courseName; int numberOfCredit; public: Course(); Course(long d, string c, int t); void setCourse(long num,string name,int cred); void printCourse(); };

#endif

Course.cpp

File Edit Options Buffers Tools C++ Help #include "Course.h" #include

Course::Course() //default constructor { courseNumber=0; courseName=""; numberOfCredit=0; } Course::Course(long d, string c, int t) //overloaded constructor { courseNumber=d; courseName=c; numberOfCredit=t; } void Course::setCourse(long num,string name,int cred) //set function { courseNumber=num; courseName=name; numberOfCredit=cred; } void Course::printCourse() //print function for display object data { cout

Instructor.h

#ifndef Instructor_H #define Instructor_H using namespace std;

class Instructor { private: string firstName; string lastName; char gender; long employeeID; string officeNum; Course courses[3];

public: Instructor(); Instructor(string firstName,string lastName,char gender,long employeeID,string officeNum,l\ ong courseNumber1, string courseName1, int numberOfCredit1);//,Course course[3]); void instructorSet(string firstName,string lastName,char gender,long employeeID,string off\ iceNum, long courseNumber1, string courseName1, int numberOfCredit1);//,Course course[3]); void printInstructor();

}; #endif

Instructor.cpp

#include "Instructor.h" #include "Course.h"

Instructor::Instructor() {

employeeID = 0; firstName = ""; lastName= ""; gender = 'M'; officeNum = ""; Course courses[3]; } Instructor::Instructor(string firstName,string lastName,char gender,long employeeID,string o\ fficeNum, long courseNumber1, string courseName1, int numberOfCredit1) { employeeID = employeeID; firstName = firstName; lastName = lastName; gender = gender; officeNum = officeNum; for(int i = 0; i

} } void Instructor::printInstructor() { cout

main

#include #include "Course.h" #include "Instructor.h" using namespace std;

int main() {

long d; string c; int p;

// Course course[3];

cout > d;

cout > c;

cout > p;

cout

// c1.setCourse(d, c, p); c1.printCourse();

Course c2; // Course(); cout

cout > d;

cout > c;

cout > p;

cout

// c1.setCourse(d, c, p); c1.printCourse();

Course c2; // Course(); cout

cout > d;

cout > c;

cout > p;

cout

// Course c3(21540, "CS211", 3);

// Instructor i("Mayssaa","Najjar",'F',2390876, "ACD324");// c3); //i.print();

return 0; }

2. After you design your classes, write a main program that instantiates 2 instructor objects and displays their information: For the first object: 1. use the overloaded constructor to create an instructor object and initialize its attributes to the following: Mayssaa Najjar F 2390876 ACD324 21540 CS211 3 21541 CS211 1 21345 CS331 3 2. Then call the print function to display the instructor object's data. For the second object, 1. use the default constructor to create an instructor object 2. call the print function to display the instructor's data 3. call the instructor set function to change the object's attributes to the following: Michelle James F 2390878 SBSB3024 24540 CS111 3 24541 CS11 22275 CS351 4. call the instructor print function to display the new object's data. Note: You will have a total of two .h files (Course.h and Instructor.h) and three.cpp files (Course.cpp, Instructor.cpp, and main.cpp)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago