Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*"To handle cases where the value of a "variable" that is initialized with a value that is not known at compile time but never changes after initialization, C++ offers a second form of costant (a const)"*/
- constexpr int max = 100;
- void use(int n)
- {
- constexpr int c1 = max+7; //OK: c1 is 107
- const int c2 = n+7; //OK, but don't try to change the value off c2
- //...
- c2 = 7; //error: c2 is a const
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement