• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 8 pages
Exam (elaborations)

Cos1512 Assignment 2 Semester 2 2022

Document preview thumbnail
Preview 2 out of 8 pages

COS1512 ASSIGNMENT 2 SEMESTER 2 2022. Introduction To Programming II. 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. 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?

Content preview

COS1512
ASSIGNMENT 2
SEMESTER 2
2022

, COS1512 Assignment 2 Semester 2
UNIQUE NUMBER
DUE DATE:


TUTORIAL MATTER: Chapters 10, 11, 12 and 15 of the Study
Guide (Tutorial Letter 102 available under
Additional Resources on the COS1512
website on myUnisa )

Chapters 10, 11, 12 (excluding “Creating a
Namespace”) and 15 (only 15.1 “Inheritance
basics”) in Savitch
Appendices 7 and 8 in Savitch

WEIGHT: 80%




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 classMeeting (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.

Document information

Uploaded on
September 8, 2022
Number of pages
8
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers
$2.80

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
DRBRIGHT2026
3.7
(191)
Sold
982
Followers
697
Items
7045
Last sold
1 week ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions