OOP for Scientific Computing First Exam
points:
1 | 2 | 3 | 4 | 5 | \(\Sigma\) |
---|---|---|---|---|---|
15 | 20 | 10 | 10 | 10 | 65 |
Following was asked in the exam:
Explain following aspects of C++ :
class
vsstruct
?namespace
. What is it, when & why is it used?private
vsprotected
?- copy elision?
- header guards. What, why?
- rule of five vs fule of zero?
- temporaries? literals?
- how does a shared pointer work?
- SFINAE?
- SOLID?
Short code snippets were given and asked to explain & extend. With following topics:
- default function args
- concepts
- template parameters, default template parameters
- Constructor, copy constructor, copy assignment operator, move constructor, move assignment operator, overloaded constructor.
- Lambda expression, functional programming
- Compile time branching
- CRTP
- Inheritence. How to improve the given implementation
Horner Schema: Variadic templates, recursion with templates(?), template metaprogramming
An incomplete implementation of an OOP system was given that was supposed to implement a simulation a prey-predator dynamic system, modeled by the Lotka-Volterra differential equations:
\[\begin{align*} &\frac{dx}{dt} = \alpha x - \beta xy, \\ &\frac{dy}{dt} = \gamma y - \delta xy \end{align*}\]
The incomplete OOP system had the following basic structure:
- Implement the
PreyPredatorData Simulate(int steps, double dt)
that creates aPreyPredatorData
object, populates its members with the simulation data based on the Lotka-Volterra difference equations and returns the object:
\[\begin{align*} &X_{n + 1} = X_n + \Delta t (\alpha x_n - \beta x_ny_n) \\ &Y_{n + 1} = Y_n + \Delta t (\delta x_ny_n- \gamma y_n) \end{align*}\]
- ?
- Implement the
?