0
Why this code is working?
Why this code is working? int string = 332; std::cout << string; But int double = 332; std::cout << double; doesn't work. I just recognized that the difference between those keywords is their color. in code::blocks string is green while double is blue. I thought that blue ones will give us errors, but I see that if we use "size_t" instead of double it won't give any errors. Could someone tell me what is the difference between these keywords and what do you call these keywords?
1 ответ
+ 4
Neither std::string nor std::size_t are keywords. Both are identifiers introduced from the STL and thus encapsulated in the standard namespace. Therefore, as long as you don't import that namespace, you may use those identifiers yourself.
On the other hand, "double" is a keyword of the language and therefore reserved. Here you can find a list of keywords:
https://en.cppreference.com/w/cpp/keyword