IPK Tutorium 13

Ablauf des TUtoriums heute

  1. Rückblick Blatt 11
    1. Bennenung der Votierenden
    2. Fragen zu Blatt 11
    3. Vorstellung von Blatt 11
  2. Eure Fragen zur Wiederholung
  3. Votieren und offene Arbeitsphase

Votieren

  • Aufgabe 11.1 - Gruppe 24 (Alex, Finja, Lev)

Aufgabe 11.1: Operator Overloading

Erinnerung: Folgendes soll funktionieren:

Point a = ...;
Point b = ...;
double d = ...;
a = a + b;
a = a - b;
a += b;
a -= b;
a = d*b;
a = b*d;
a *= d;
std::cout << a << std::endl;
#ifndef NBODY_SIM_POINT_H
#define NBODY_SIM_POINT_H

#include <iostream>

struct Point {
  // coordinates
  double x;
  double y;

public:
    Point();
    Point(double x_p, double y_p);

    Point operator+(const Point& b);
    Point operator-(const Point& b);

    Point& operator*=(double d);
    Point& operator+=(const Point& b);
    Point& operator-=(const Point& b);

    friend Point operator*(const double& d, const Point& b);
    friend Point operator*(const Point& b, const double& d);

    friend std::ostream& operator<<(std::ostream& os, const Point& a);
};

#endif //NBODY_SIM_POINT_H

Aufgabe 11.2: Lambda die erste

Erinnerung:
Implementieren Sie eine Lambda Funktion in der Funktion "simulateNBody" in der Datei "nbody.h".

Gibts Fragen Zu Blatt 11?

Sonst gerne auch gleich in der Übungsphase!

IPK Tutorium 13

By Christian Heusel