COS 1512 ASSIGNMENT 2
Question 1 Consider the following structure used to keep record of a meeting: struct Meeting { string speaker; string topic; string venue; string date; } Turn the meeting struct into a class. The class should have member variables for all the values in the corresponding struct. Make all member variables private. Include public member functions for each of the following: a default constructor that sets the string data members to blank strings; member functions to set each of the member variables to a value given as an argument to the function (i.e. mutators); member functions to retrieve the data from each of the member variables (i.e. accessors); Test the class in a program that instantiates an object of class Meeting (i.e. ‘declare’ an object of ‘type’ Meeting). The program should then input values for the object (obtained from the keyboard), and use the mutators to assign values to the member variables. Use the accessors to obtain the values of the member variables of the object and display those values on the screen. Test your program with appropriate input. This study source was downloaded by from CourseH on :38:34 GMT -05:00 This study resource was shared via CourseH Question 2 – a bit of theory and terminology (a) What is the purpose of the keywords public and private in the class declaration? (b) What is the difference between a class and an object? (c) What does it mean to ‘instantiate’ an object? (d) What is the purpose of a constructor? (e) What is the difference between the default constructor and the overloaded constructor? (f) What is the purpose of a destructor? (g) What is the purpose of an accessor? (h) What is the purpose of a mutator? (i) What is the purpose of the scope resolution operator? (j) What is the difference between the scope resolution operator and the dot operator? (k) What is the difference between a member function and an ordinary function? (l) What is an abstract data type (ADT)? (m) How do we crea
Written for
- Institution
-
Johns Hopkins University
- Course
-
COS 1512 ASSIGNMENT 2
Document information
- Uploaded on
- September 9, 2021
- Number of pages
- 8
- Written in
- 2021/2022
- Type
- Exam (elaborations)
- Contains
- Questions & answers