•Esther Miriam ZimmerLederberg was an Americanmicrobiologist and a pioneerof bacterial genetics. Notablecontributions include thediscovery of the bacterialvirus λ, the transfer of genesbetween•Born: December 18, 1922,The Bronx, New York City, NY•Died: November 11, 2006,Stanford, CA•Spouse:Joshua Lederberg(m. 1946)•Field:Microbiology•Education: University ofWisconsin-Madison,Stanford University
CST2403 28875 N921C++ Programming Part 1Professor: Patrick ChiuEmail: [email protected]omText: C++ How to Program, seventh edition, Prentice-HallH.M. Deitel and P.J. Deitel
CST2403Fall Schedule:DateEvent29-NovQuit#41-DecRecords posting and review6-DecExercise8-DecSummary15-DecFinal Examination
TopicsReadingWeek 14Class and ObjectChapter 3
// Define class GradeBook with a member function displayMessage,// create a GradeBook object, and call its displayMessage function.#include <iostream>using namespace std;// GradeBook class definitionclass GradeBook{public:// function that displays a welcome message to the GradeBook uservoid displayMessage(){cout << "Welcome to the Grade Book!" << endl;} // end function displayMessage}; // end class GradeBook// function main begins program executionint main(){GradeBook myGradeBook; // create a GradeBook object named myGradeBookmyGradeBook.displayMessage(); // call object's displayMessage function} // end main
GradeBook+ displayMessage()Unified Modeling Language (UML) class diagram indicatingthat class GradeBook has a public displayMessageoperation.AttributesMember Function
#include <iostream>#include <string> // program uses C++ standard string clusing namespace std;// GradeBook class definitionclass GradeBook {public:// function that displays a welcome message to the GradeBook uservoid displayMessage( string courseName) {cout << "Welcome to the grade book for\n" << courseName << "!"<< endl;} // end function displayMessage};int main() {string nameOfCourse; // string of characters to store the course nameGradeBook myGradeBook; // create a GradeBook object named myGradeBook// prompt for and input course namecout << "Please enter the course name:" << endl;getline( cin, nameOfCourse ); // read a course name with blankscout << endl; // output a blank line// call myGradeBook's displayMessage function// and pass nameOfCourse as an argumentmyGradeBook.displayMessage( nameOfCourse );} // end main
#include <iostream>#include <string> // program uses C++ standard string classusing namespace std;// GradeBook class definitionclass GradeBook {public:// function that sets the course namevoid setCourseName( string name ) {courseName = name; // store the course name in the object} // end function setCourseName// function that gets the course namestring getCourseName() {return courseName; // return the object's courseName} // end function getCourseName// function that displays a welcome messagevoid displayMessage() {// this statement calls getCourseName to get the// name of the course this GradeBook representscout << "Welcome to the grade book for\n" << getCourseName()<< “!” << endl;} // end function displayMessageprivate:string courseName; // course name for this GradeB}; // end class GradeBook// function main begins program execution
Upload your study docs or become a
Course Hero member to access this document
Upload your study docs or become a
Course Hero member to access this document
End of preview. Want to read all 32 pages?
Upload your study docs or become a
Course Hero member to access this document