I was asked this question in a technical interview:
What is the difference between a
constand a macro in C++?
My a
sample: source : main.cpp
#define int_constance 4
#define int_constance 8 // ok, compiler will warning ( redefine macro)
const int a = 2;
const int a = 4; // redefine -> error
int main(int argc, char** argv)
{
std::cout << int_constance ; // if remove second #define line, output will be 8
return 0;
}