Object Oriented Programming

Base Knowledge

Programming in C language and algorithms. It is important that students have passed the 1st year Introduction to Programming and Programming curricular units.

Teaching Methodologies

The classes are theoretical and practical. In the theoretical classes, an expository methodology is used to present the theoretical foundations of the subject with application examples, and student participation is encouraged with the aim of fostering an interactive learning environment. In the practical classes, students apply the knowledge from the theoretical lessons by developing applications under the supervision of the instructors, and student participation in the class is required. Outside of class, students work in pairs to develop a project that applies and deepens the topics covered in the lessons, and the project is subject to evaluation.

Learning Results

1. Acquire object-oriented programming skills.

2. Acquire object-oriented programming skills in C++.

3. Acquire the ability to develop console C++ applications.

4. Acquire the ability to develop applications based on encapsulated and polymorphic data structures.

5. Improve the ability to organize, research, plan, justify solutions and document software projects.

6. Improve the aptitude for autonomous information research.

Program

General introduction to object-oriented concepts and the C++ language

  • General Concepts of Object Oriented Programming
  • Encapsulation, Polymorphism, Inheritance
  • SOLID Principles

 

Some differences between C and C++

  • Standard data input and output Structuring projects in .h and .cpp
  • Comments in C++
  • Definition of local variables
  • Predefined types
  • Type cast
  • References
  • Constants
  • Functions
  • Overloaded Functions
  • Functions with default arguments
  • Ambiguity situations in overloading

 

Classes

  • Class definition syntax
  • Classes as Structure evolution
  • Member functions
  • The this pointer
  • Inline Functions
  • Visibility (accessibility)
  • Constructors
  • Initialization syntax () and {}
  • initializer_list
  • Non-dynamic arrays of objects
  • Destructors
  • Inline member functions
  • static members: data and functions
  • constant member functions
  • friend functions

 

Objects life cycle

  • Destructor
  • Introduction to copy construction
  • Assignment. Introduction to the assignment operator

 

Dynamic objects

  • The new and delete operators
  • Dynamic arrays of objects

 

Operator overloading

  • General Introduction to Operator Overloading
  • Operator Functions
  • Unary and binary operators
  • Choice of member operators vs. non-member operators
  • Conversions operators

 

Composition and aggregation

  • Meaning of composition versus aggregation
  • Composition without dynamic memory – syntax, initialization requirements. Constructors and Destructors calling order
  • Aggregation by reference and pointer

 

Composition through dynamic memory

  • Concept of managing own resources in classes
  • Data members that are pointers to dynamic memory
  • Destructor, Assignment Operator, Copy Constructor

 

Object composition

  • Composition of objects and constructors
  • Basic Types in initialization list
  • Composition of objects and destructors

 

Inheritance in C++

  •  Derived classes
  •  Composition vs. derivation
  •  Forms of derivation and accessibility
  •  Constructors and destructors
  •  Copy constructor and assignment operator on derived classes
  •  Inheritance and overloaded functions

 

Polymorphism

  • Upcasting
  • Virtual functions
  • Abstract classes and pure virtual functions
  • Overloaded virtual functions and redefinition in derived classes
  • Virtual destructors

 

C++ Exception Mechanism

 

Introduction to the STL library

  • Notion of container and iterator
  • Classes of containers. Container manipulation.
  • Class vector. Class map. Classes for string manipulation. String, istringstream, ostringstream
  • Classes for stream I/O support ifstream and ofstream

 

Introduction to smartpointers in C++

  • unique pointer
  • shared pointer
  • weak pointer

Introduction to templates and STL library

  • Class Templates
  • Template arguments
  • Function templates

Curricular Unit Teachers

João António Pereira Almeida Durães

Grading Methods

Assessment consists of two components: an exam and a practical assignment.

Practical assignment:

  • The assignment may be carried out individually or in groups of two students enrolled in the same laboratory class.
  • The assignment is carried out exclusively during the semester. Students who do not complete the assignment during the semester will permanently forfeit the corresponding marks and may not replace it by any other means or through the exam, in any assessment period.
  • The assignment is described in one or more specifications, which will be made available at the appropriate time and will contain details of the applicable requirements and rules.
  • The assignment is subject to three progress monitoring and presentation sessions, to be held during classes specified in the assignment description.
  • Failure to attend any of these sessions will result in the permanent loss of part of the marks allocated to the assignment, as specified in the assignment description. Progress monitoring and presentations take place in the laboratory class in which the student is enrolled.
  • Students formally registered in NONIO as having working-student status may choose to attend the progress monitoring sessions outside their regular class, at a time to be agreed with the lecturer.
  • The assignment may be assessed according to one of two alternative profiles: Profile A, in which the assignment is worth 2.5 marks, or Profile B, in which it is worth 4 marks. The exam will be worth the remaining marks required to make up a total of 20 marks.
  • Under Profile A, the assignment is worth 2.5 marks and assessment consists solely of the three progress monitoring sessions, during which progress, compliance with the requirements, and aspects related to the quality of the solution are assessed, with greater emphasis on the third session. After the third assessment session, the student is informed of the mark obtained.
  • Under Profile B, the assignment is worth 4 marks and requires an additional defence, similar in nature to an oral examination, in which the student's command of the subject matter involved is assessed in detail. The result of this defence may lower the mark already obtained in the third assessment session.
  • By default, all students are assessed under Profile A. At the end of the third progress monitoring session, a student may choose to switch to Profile B. Students who choose to do so must register for a time slot for the defence. The final assignment mark will be determined on the basis of the mark already obtained and the student's performance in the defence.
  • The choice of Profile B is individual, even when the assignment is carried out by a group of two students. Switching to Profile B is voluntary but final.
  • Assignments from previous years: only assignments completed in the 2025/2026 academic year may be carried over. Participation in any progress monitoring session for the current academic year's assignment eliminates the possibility of carrying over the assignment from the previous year. An assignment carried over from the previous academic year is worth 4 marks.
  • Students who neither submit an assignment nor choose to carry over the assignment from the previous academic year are assumed to be under Profile A and therefore forfeit the 2.5 marks corresponding to the practical assignment.

Exam:

  • A written examination, held during the official assessment periods and on the dates established by the School.
  • The exam is worth the remaining marks required to make up a total of 20 marks, depending on the student's practical assignment profile.
  • The exam is subject to a minimum passing mark of 35%.
  • During the exam, students may only access the materials specified by the lecturers.
  • Registration may be required in order to take the exam during the regular assessment period. This registration does not replace enrolment in the course unit or registration for the exam through the Academic Services and is intended solely to optimise the allocation of rooms and invigilators.

Oral validation:

  • Any assessment may be subject to oral validation. The lecturers will determine whether such validation is required. It may apply to any assessment, including exams, and may be required of all students or only some students. The students concerned will be informed accordingly.

    Internship(s)

    NAO

    Bibliography

    Main references

    Brokken, F. B. (2024).  C++ Annotations Version 13.0.0, University of Groningen publishing, http://www.icce.rug.nl/documents/cplusplus/   –  online

    Stroustrup, B. (2000). A linguagem de programação C++, Bookman – 1ª-1-359

     

    Auxiliary references

    Lippman, S.B., Lajoie, J., Moo B. E. (2013).  C++ Primer (5th ed.), Addison-Wesley

    Eckel, B. (2000). Thinking in C++  Vol.1 (2nd ed.), Prentice Hall Inc., http://www.bruceeckel.com/  –  1A-1-380 / Online

    Deitel, P. J., Deitel, H. M. (2010). C++ How to Program (7th edition), Prentice Hall Inc. – 1A-1-425