Random C++ questions from a C# programmer
Posted: May 5th, 2020, 6:33 pm
I've recently come back to Chili's tutorials after a long while and as I'm learning I keep wondering about some aspects of C++ that seem peculiar to me.
So, in no particular order:
1.) Is there a consistent naming convention in the standard library? Is it defined somewhere?
2.) Why do names have to be fully qualified? I know you can use "using namespace std;" but it's discouraged. What I'm trying to understand here is, from a technical standpoint, why can you litter your source files in C# with using statements without issue, but it causes problems in C++? Couldn't C++ just force you to fully qualify ambiguities as in C#?
3.) A lot of the names of functions or member variables seem unintuitive. Perhaps this is due to my unfamiliarity with the language, but to provide one specific example: vector.push_back, why push_back? Why not add?
4.) Some of the standard library classes lack functionality that I would expect. For example, std::string contains no tolower/toupper functions, another example, vector has no contains function. I know some of this functionality is in algorithm, but why wouldn't it be part of the class?
Anyway, I'm trying to better understand the design philosophy of C++ and some things just look really weird to me from my C# background. I'm really enjoying the series. Chili is a very engaging teacher.
So, in no particular order:
1.) Is there a consistent naming convention in the standard library? Is it defined somewhere?
2.) Why do names have to be fully qualified? I know you can use "using namespace std;" but it's discouraged. What I'm trying to understand here is, from a technical standpoint, why can you litter your source files in C# with using statements without issue, but it causes problems in C++? Couldn't C++ just force you to fully qualify ambiguities as in C#?
3.) A lot of the names of functions or member variables seem unintuitive. Perhaps this is due to my unfamiliarity with the language, but to provide one specific example: vector.push_back, why push_back? Why not add?
4.) Some of the standard library classes lack functionality that I would expect. For example, std::string contains no tolower/toupper functions, another example, vector has no contains function. I know some of this functionality is in algorithm, but why wouldn't it be part of the class?
Anyway, I'm trying to better understand the design philosophy of C++ and some things just look really weird to me from my C# background. I'm really enjoying the series. Chili is a very engaging teacher.