namespace cpp {}

C++ lernen, kennen, anwenden

Benutzer-Werkzeuge

Webseiten-Werkzeuge


kennen:beispiel:constexpr

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';
}
kennen/beispiel/constexpr.txt · Zuletzt geändert: 2017-04-19 21:39 von 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki