

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A programming assignment for creating a c++ class, including class definition, member functions, and constructors. Students will learn how to instantiate an object of the class and perform operations such as setting the day, printing the day, and returning the next and previous day. The document also includes instructions for downloading and compiling the provided daytype stub.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Name: Sec: 07/03/
Recall that the two structured data types we have studied so far are arrays, which have elements all of the same type, and structures, which have elements of differing types. Another structured data type is a class, which is specifically designed to combine data and functions in a single unit. A class is a collection of a fixed number of components. The components of a class are called the members of the class. If a member of a class is a variable, you define it just like any other variable, but you cannot initialize it at definition. If a member of a class is a function, you typically use the function prototype to define that member. Member functions can directly access any data member of the class without passing that data member as an argument. No memory is allocated in a class definition. Instead, memory is allocated when the class is instantiated (an object is created). Additionally, the semicolon (;) is part of the syntax at the end of the class definition. The members of a class are classified into three categories: private, public, and protected. By default, all members of a class are private. Private members cannot be accessed outside of the class. A public member is accessible outside the class.
In this assignment you will learn how to define a class and declare and use instances of the class. After completing this assignment, you will be able to: Write a header and source file that contains a class definition. Instantiate an object of a class. Work with multiple files for a single programming project.
Part 1: Download, compile and run the DayType stub In order to make getting started with this assignment a little easier, I have provided 3 files for you that take care of some of the details you will need when creating a class. The files are called DayType.h, DayType.cpp and DayTypeTest.cpp. You should download these files, create a project in the IDE of your choice, and then add and make sure you can compile and run the stub
program. The DayType class I provide doesn't do anything yet, you will have to fill in the details for your part of the assignment. Part 2: Implement the DayType class For your assignment, you should implement the following functionality for the DayType class. The class DayType should store the day, such as Sun for Sunday, Mon for Monday, etc. (use a string or maybe even better an enumerated type see pg. 420). The program should be able to perform the following operations on an object of type DayType (these will all be member functions you need to implement):
You have now completed Assignment 5. If your program compiles and runs correctly and you have successfully uploaded your source file to the eCollege online submission site, then you are done.