I have a problem with multiple use constexpr C++17.
#include <iostream>
int main()
{
static constexpr bool condition_a = true;
if constexpr (condition_a)
{
// I create object A
int A = 10;
}
if constexpr (condition_a)
{
// I try to use object A
std::cout << "out " << A << std::endl;
}
}
Compiler return: “error: ‘A’ was not declared in this scope”
How can I create this object and use in next if statement?
New contributor
ppawel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3