WEST VIRGINIA UNIVERSITY
COLLEGE OF ENGINEERING
DEPARTMENT OF ELECTRICAL AND
COMPUTER ENGINEERING
COMPUTER ENGINEERING LABORATORY ON OBJECT-ORIENTED PROGRAMMING IN C++
LAB #1
Objectives:
- Program Structure: Dissect a
C++ program, and look through the error messages produced when an
important part is missing or incorrectly specified.
- Interactive Development
Environments (IDE); Practice the use of a C++ IDE
Procedure:
- Run the pixel.cpp
(see footnote) program discussed in class using any C++ IDE with different
values for the point locations (e.g., a starting location of (0,0) and
move it to the opposit diagonal location). Write detailed comments in the
program to describe the important parts of the program. Start with a
comment at the top describing the program as a whole.
- Edit the file point.h and modify it as shown below, then
compile the .cpp files and record the compilation errors listed in each
case.
- Delete the
";" located after the closing braket (i.e., "}") of
the class Location.
- Change the name of
function Location in the public part of class Location to
"location"(i.e., with a lower case 'l').
- The function Point in
class Point has two arguments. Delete the" int" keyword located
in front of each argument.
- Edit the file point2.cpp, delete the class designation
"Location::" located in front of the function GetX, compile the
program and record the effect of this change.
- Use the debugging utility in
your IDE to step over the execution of pixel.cpp.
Use the Watch Window to watch the behaviour of the object Apoint.
- Edit the file pixel.cpp, expand function main to create two
additional Point objects (e.g., Bpoint, and Cpoint) adjacent to Apoint.
Show all pixels and move them together.
- Load and run the programs circle.prj and mcircle.prj.
Describe the added functionality in each program.
- Comment briefly in your
report on the OOP concepts of encapsulation and inheritance discussed in
class by giving examples from the above programs.
pixel.cpp program is in the directory
G:\lang\turbocpp\examples , load it using the "open project" option
in the project menu of the IDE. The program consists of the files point.h, pixel.cpp and point2.cpp .