What is the difference between const and constexpr?

Answers were Sorted based on User's Feedback



What is the difference between const and constexpr?..

Answer / nashiinformaticssolutions

• const: Value remains constant; evaluated at runtime.
• constexpr: Evaluated at compile time for optimization.

Is This Answer Correct ?    0 Yes 0 No

What is the difference between const and constexpr?..

Answer / nashiinformaticssolutions

o const: The value is constant and determined at runtime or compile-time.
o constexpr: The value is constant and must be computed at compile-time.

Is This Answer Correct ?    0 Yes 0 No

What is the difference between const and constexpr?..

Answer / glibwaresoftsolutions

• const: Value remains constant; evaluated at runtime.
• constexpr: Evaluated at compile time for optimization.

Is This Answer Correct ?    0 Yes 0 No

What is the difference between const and constexpr?..

Answer / hr@tgksolutions.com

• const: Value remains constant; evaluated at runtime.
• constexpr: Evaluated at compile time for optimization.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What are function poinetrs? where are they used?

1 Answers   CTS,


What are the various oops concepts in c++?

1 Answers  


If a function doesn’t return a value, how do you declare the function?

1 Answers  


What are pointers used for c++?

1 Answers  


What are the uses of static class data?

1 Answers  


What is the most common mistake on c++ and oo projects?

1 Answers  


When can you tell that a memory leak will occur?

1 Answers  


What is an operator function? Describe the function of an operator function?

1 Answers   Fidelity,


What are formatting flags in ios class?

1 Answers  


What is the output of: String a1 = "Hello"; String a2 = "world!"; String* s1 = &a2; String& s2 = a1; s1 = &a1; s2 = a2; std::cout << *s1 << " " << s2 << std::endl;

4 Answers   Lehman Brothers,


What is rvalue?

1 Answers  


Disadvantages of c++

8 Answers   HCL,


Categories