Why vector, variant and any are not keywords? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why vector, variant and any are not keywords?

I was looking for the list of keywords in C++ in cppreference website which very famous for its c++ content and i saw that in that they didn't mention vector as keyword(vector is not present in that table) and including some other keywords such as variant, any, optional and thread. So why these are not keywords because we cannot use them as variable if we are using there library?

3rd Oct 2020, 5:47 PM
Abhishek Dimri
Abhishek Dimri - avatar
3 Answers
+ 1
They are not keywords because they are not part of the core language. ( everything in C++ you can use without a header ) Vector, variant and any and the likes are implemented using the core language and are part of the standard library which comes with the language. You can use them as variable names if you really want to, albeit not recommended.
3rd Oct 2020, 7:06 PM
Dennis
Dennis - avatar
0
Dennis You mean I can access all other 97 keywords without header files?
4th Oct 2020, 5:45 AM
Abhishek Dimri
Abhishek Dimri - avatar
4th Oct 2020, 7:56 AM
Dennis
Dennis - avatar