/* returnConst.cpp */
#include <iostream>

using namespace std;



class Point {
  double x;
  double y;
public:
  Point(double x = 0, double y = 0) : x(x), y(y) { }

  void setX(double x = 0) {
    this->x = x;
  }
};



const Point f(Point p) {
  return p;
}




int main() {
  Point p, p2(22, 33);

  p = f(p2);             // Funktioniert! Weshalb wohl?

// f(p2).setX(8)         // Fehler:
                         //  passing `const Point' as `this' argument of
                         //  `void Point::setX(double = 0)' discards
                         //  qualifiers

// f(p2) = p;            // Fuehrt zu Fehlermeldung:
                         //  passing `const Point' as `this' argument of
                         //  `class Point & Point::operator =(const Point &)'
                         //  discards qualifiers

  return 0;
}
