/
githubmirror
/
CPlusPlusThings
Обзор
Документация
Войти
/
githubmirror
/
CPlusPlusThings
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
learn_class/modern_cpp_30/constexpr/test3.cpp
25 строк
541 B
zhangxing
support bazel complie this project and format code.
30 мар 2024, 17:00
30 мар 2024, 17:00
3c8a3f2
Код
Авторство
О чём код?
// // Created by light on 20-1-10. // #include <iostream> class test3 { public: int value; // constexpr const method - can't chanage the values of object fields and can // be evaluated at compile time. constexpr int getvalue() const { return (value); } constexpr test3(int Value) : value(Value) {} }; int main() { // 加不加都行 constexpr test3 x(100); // OK. Constructor is constexpr. int array[x.getvalue()]; // OK. x.getvalue() is constexpr and can be evaluated // at compile time. }