Laboratory 4: Classes
I. Understand Classes.
Goals:
1. To be able to implement your own classes
2. To master the separation of interface and implementation
3. To understand the concept of encapsulation
4. To understand object construction
5. To learn how to distribute a program over multiple source files
- Example 1
bee.cpp
This small example demonstrates the use and syntax of class methods and
variables. Explain the difference between class and
instance variables! What if F was an instance
variable?
- Example 2
exception.cpp
Study how exceptions are thrown.
- Example 3
pmem.cpp
Study the syntax of pointers to member functions. What is the difference
between a pointer to a non-member function and a pointer to a function? Make
sure you understand the output!
- Example 4
bestval.cpp
- Example 5
product1.cpp
- Example 6
product2.cpp
- Example 7
product.h
product.cpp
prodtest.cpp
II. Operator Overloading.