Beispiel constexpr

constexpr.cpp
#include <iostream>
 
constexpr int square(int n) 
{
  return n*n;
}
 
constexpr int q = square(3); 
 
struct Point
{
  constexpr Point(int x, int y) : x(x), y(y) {}
  int x, y;
};
 
constexpr Point p{4, square(4)};
 
int main()
{
  std::cout << p.x << ' ' << p.y <<  '\n';
}