Horje
c++ define constant in class header Code Example
c++ define constant in class header
class Foo
{
public:
    const int a = 5; // Valid use of const.
    constexpr int b = 7; // Invalid use of constexpr, won't even compile!
    static constexpr int c = 10; // Valid use of constexpr.

    int arrA[a]; // ERROR: 'a' is defined at runtime, so you can't use it to define a size.
    int arrB[b]; // ERROR: You couldn't even define 'b', so this is not going to work...
    int arrC[c]; // VALID: 'c' is known by the compiler, and is guaranteed to only ever be 10!
}




Cpp

Related
Statements Code Example Statements Code Example
options select from array Code Example options select from array Code Example
get list of files in directory c++ Code Example get list of files in directory c++ Code Example
why return 0 in int main Code Example why return 0 in int main Code Example
shift element to end of vector c++ Code Example shift element to end of vector c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
13