Back to Quizzes

Exam 1

There will be one programing question and a few short answer questions on C++. The programing question will be in an enviroment identical to the PotDs. It will require programming complete and correct C++ programs. Partial credit will only be given for working, compilable code that passes some test cases. Code that doesnt compile will not receive any credit. Multiple (but not unlimited) submissions will be allowed.

Changed due to issues Exam now as follows

We have also decided to simplify the exam. We had originally been designing the exam with the mistaken belief that it was happening all after mp_stickers was due. Since that is not the case we have simplified the exam. You will instead be programming a small function that will work on a class we are providing you. You can find the header below. You will be asked to write a small function that will take a Matrix by reference and return a Matrix.

Once again I personally apologize about the issues with this exam. It is my fault and I will make sure it will not happen again. Thank you for your understanding.

G Carl Evans

—begin matrix.h—

#pragma once

namespace exam {
    class Matrix {
        public:
            Matrix();
            Matrix(int rows, int columns);
            Matrix(const Matrix &m);
            Matrix & operator=(const Matrix &m);
            ~Matrix();

            int get_coord(int rows, int columns) const;
            void set_coord(int rows, int columns, int i);

            int get_num_rows() const;
            int get_num_columns() const;

            void display();

        private:

            int *data_;
            int num_rows_;
            int num_columns_;

            void _destroy();
            void _copy(const Matrix & m);
    };
}

—end matrix.h—

Programing Question

The programing question will give you a class that is similar to Image from mp_stickers with one method unimplemented. You will be asked to implement that method. Possible methods would be.

  • Mirror the image left to right or top to bottom
  • Rotate the square image 90 degrees left or right
  • shuffle the image swapping odd and even rows
  • Color flip the image around a particular hue

You will not have to resize the image or change its aspect ratio.

Short Answer Toics

  • Classes in C++
    • Public members functions
    • Private helper functions
    • Private variables
    • Constructors
    • Automatic default constructor
    • Custom constructors (default and non-default)
    • Copy constructor
    • Automatic copy constructor
    • Custom copy constructor
  • Namespaces in C++
    • Creating a class that is part of a namespace (eg: Cube is part of the cs225 namespace)
    • Using a class from a namespace (eg: cs225::Cube)
    • Purpose and usefulness of namespaces
  • Variables
    • Four properties: name, type, location (in memory), and value
    • Primitive vs. user-defined
  • Memory
    • Indirection in C++:
      • Reference variables
      • Pointers
      • Differences and trade-offs between each type
    • Stack memory
    • Heap memory
  • Functions: Calling and Returning
    • Pass by value, by reference, and by pointer
    • Return by value, by reference, and by pointer

Assignments referenced:

  • lab_debug
  • lab_memory
  • mp_stickers

Points:60

Start: Sunday, September 11

End: Tuesday, September 13