I´ve found a comment of user R..:
C and C++ are not the same language. In particular, C
const
has nothing to do with C++const
.
I know, that one difference between the const
qualifier in C and the const
qualifier in C++ is its default linkage.
An object declared at namespace scope with const
qualifier in C++ has internal linkage, while in C an object with const
qualifier declared at global scope (without having a static
qualifier before const
) has external linkage.
But how else do they both differ between the languages of C and C++? I´ve thought both have the same kind of concept and purpose in both languages.
My Question:
- What is the difference between the const qualifier in C and the const qualifier in C++?
The answers to How does "const" differ in C and C++? do not point an exact difference between the languages of C and C++ in the context of the const
qualifier. Only what you can´t do or can do with it in a certain language.
const
doesn't have anything to do with linkage. You can havestatic const
at file scope and it has internal linkage, – Spireletconst
does the same in both languages. – Spireletconst int a = 34;
withoutstatic
has external linkage by default, whilestatic const int a = 34;
indeed has internal linkage. – Dessau