Computer Engineering Lab on Object-Oriented Programming in C++

WEST VIRGINIA UNIVERSITY
COLLEGE OF ENGINEERING

DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

COMPUTER ENGINEERING LABORATORY ON OBJECT-ORIENTED PROGRAMMING IN C++

LAB #1

Objectives:

  1. Program Structure: Dissect a C++ program, and look through the error messages produced when an important part is missing or incorrectly specified.
  2. Interactive Development Environments (IDE); Practice the use of a C++ IDE

Procedure:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. Load and run the programs circle.prj and mcircle.prj. Describe the added functionality in each program.
  7. 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 .