Institute of Computer Science
  1. Courses
  2. 2022/23 spring
  3. Programming in C++_ENG (MTAT.03.158)
ET
Log in

Programming in C++_ENG 2022/23 spring

  • Home
  • Labs
    • Submission of solutions
    • Results
  • Examination times
  • Guides
  • References

Sample Exam

While it is crucial to write clean and error-free code during the examination, we understand that minor syntax errors, such as missing semicolons or other similar issues, may occur. Therefore, we want to reassure you that these syntax errors will not heavily impact your grading.

Write a program that has a base class named Quad. This class should have four member data variables (floats) representing side lenghts and a virtual function Area, which just returns 0. It should also have a method for setting the data variables. Derive a class Rectangle from Quad and override the Area method so that it returns the area of the Rectangle. Write a main function that creates a variable of type pointer to Rectangle and assigns a Rectangle to it which is created on the heap. Set the side lengths to some positive values, which actually form a rectangle. Use the Area function to calculate the size of the rectangle and print this out.

Do you see any issues with the modelling of the rectangle? If so, suggest improvements to the rectangle class which overcome the problem.

Short questions (perhaps I will ask this as multiple choice):

  • What is the difference between i++ and ++i ?
  • What is the difference between public , private and protected class access rights ?
  • How do the same access rights work if the class also has a superclass with some kind of access rights? (Which functions are visible and what are not?)
  • What is the syntax for documenting a Doxygen function?
  • What does the life cycle of an object look like (when is the constructor called , when is the destructor called, what happens in between?)
  • How to get elements from an array ?
  • How do you get elements from an array of pointers ?
  • How do you get the nth element when the array contains only pointers?
  • What is the difference between a pointer and a reference and how do they work in the context of classes. (How to access variables/methods?)
  • The nature of the delete command, when to delete and when to delete[] .
  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment