


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
Instructions for creating a simple money structure and a full-blown exchange class in c++. It covers creating files, defining structures and classes, implementing member functions, and testing the code. The objective is to learn how to define and use classes, instantiate objects, and perform data conversions.
Typology: Lab Reports
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Name: Sec: 07/11/
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. Protected members will be discussed in Chapter 13.
In this lab, you define a class and declare objects. After completing this lab, you will be able to:
single character to represent the monatary type. The amount will be, as suggested by the name, the amount of Pesos, Rubles, Dollars, etc respectively being saved in the structure.
You have now completed Lab 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.