Module 4: Classes - Abstraction and Encapsulation
- First read this page then start coding module with the GitHub classroom link below.
- Github Classroom Link: https://classroom.github.com/a/QPPg5wo4
Class implementation:
Implement the class
that you designed in the breakout activity during lecture.
Create a .h
header file for your class. In your header file declare the class.
You should include the following:
- Use the
#include
guard around your code in the header file. (see below example) - A constructor to construct your class.
- Access modifiers
public
andprivate
- Method declarations for the
class
` member functions. - Member variables for the
class
data.
Next create a .cpp
code file where you will implement the member functions that you declared in your class.
Remember to:
- Include the header file for your class.
- Use the
::
scope resolution operator to access your class. - Implement the constructor, if one was needed.
- Implement all of the methods of your class.
Example of the include guard:
#ifndef MY_CLASS_H
#define MY_CLASS_H
// Declare your class here...
#endif
Note: Your code should compile and be well documented with code comments. But it does not have to be completely implemented such that everything operates fully. In other words, some methods may be “stubbed” out to only print out (cout
) “in method X”. This is an exercise to get comfortable with the C++ class
syntax.