I am interested in learning C++, and I found a book that seems to be the right fit for me. However, even though the book is quite new, some readers criticized that an earlier version of the book did not really dive into the new C++ standards (such as C++11, C++14, C++17) and rather used the "old C++ standard" (i.e., pre C++11).
While I checked if the newer version covered the new aspects of C++11 etc. (and it seemed like it covered quite a few), I am uncertain if possibly learning a pre C++11 standard would be inefficient? It seems like the new version does covers the new C++ standards (C++11 and upwards), but let's assume it does not. Would the knowledge I gain be outdated?
Again, I am new to C++, so I am not sure if the newer C++ standards completely changed the language, possibly removing/changing (integral) parts of the language which I would learn with this (possibly outdated) book. I just want to avoid learning (integral) parts of the language which are not used anymore or which are used differently nowadays (with the newer standards). However, if all the new C++ standards did was adding new features (but not removing/changing old features), I don't think learning from the book would be an issue since I could simply learn the newer features afterwards.
So in what ways did the newer C++ standards change the language, and would you say learning from a possibly outdated book is an issue?
Switching from C to C++ can be both easy, as there are many similarities between the two languages, and hard, as there are many differences that require forgetting what you know and habits that you may have developed from programming in C.
There is no need to learn C before learning C++. They are different languages. It is a common misconception that C++ is in some way dependent on C and not a fully specified language on its own. Just because C++ shares a lot of the same syntax and a lot of the same semantics, does not mean you need to learn C first.
Likewise, the educational program isn't excessively intricate or tedious to follow, as all you require is to experience a few subjects every day and you'll cover the whole schedule in basically 10 days. Along these lines, plunge into the C language world and improve your programming abilities for new job openings!
We recommend choosing the latest standard “ISO C++ Latest (/std:c++latest)”, which as of the time of writing is the setting for C++20 support. For more information on Visual Studio language standard settings, Microsoft has a Visual Studio language standard reference document.
There is no need to learn C before learning C++. They are different languages. It is a common misconception that C++ is in some way dependent on C and not a fully specified language on its own. Just because C++ shares a lot of the same syntax and a lot of the same semantics, does not mean you need to learn C first.
The C Standard Library is a set of C built-in functions, constants and header files like <stdio.h>, <stdlib.h>, <math.h>, etc. This library will work as a reference manual for C programmers. The C Standard Library is a reference for C programmers to help them in their projects related to system programming.
The answer to all such questions is C standard. In all such cases, we need to see what C standard says about such programs. What is C standard? The latest C standard is ISO/IEC 9899:2011, also known as C11 as the final draft was published in 2011. Before C11, there was C99. The C11 final draft is available here.
What is C standard? The latest C standard is ISO/IEC 9899:2011, also known as C11 as the final draft was published in 2011. Before C11, there was C99. The C11 final draft is available here. See this for a complete history of C standards. Can we know the behavior of all programs from C standard?
Some code have changed in C++11, main changes, IMO, are:
way to "return" big object:
void MakeVector(std::vector<int>& v) {
v.clear();
// fill v;
}
std::vector<int> MakeVector() {
std::vector<int> v;
// fill v;
return v;
}
way to iterate container:
void Foo(std::vector<int>& v) {
for (std::vector<int>::iterator it = v.begin(); it != v.end(); ++it) { /* *it ..*/ }
for (std::size_t i = 0; i != v.size(); ++i) { /* v[i] ..*/ }
}
end()
is computed only once)):void Foo(std::vector<int>& v) {
for (int& e : v) { /* ..*/ }
}
way to write types:
void Foo(std::vector<int>& v) {
std::vector<int>::iterator it = std::find(v.begin(), v.end(), 42);
// ...
}
void Foo(std::vector<int>& v) {
auto it = std::find(v.begin(), v.end(), 42);
// ...
}
way to create predicate:
bool less_than_42(int i) { return i < 42; }
struct less_than_x {
less_than_x(int x) : x(x) {}
bool operator()(int i) const { return i < x; }
int x;
};
void Foo(std::vector<int>& v, int x) {
std::vector<int>::iterator it1 = std::find_if(v.begin(), v.end(), less_than_42);
std::vector<int>::iterator it2 = std::find_if(v.begin(), v.end(), less_than_x(x));
// ...
}
void Foo(std::vector<int>& v, int x) {
auto it1 = std::find_if(v.begin(), v.end(), [](int e){ return e < 42; });
auto it2 = std::find_if(v.begin(), v.end(), [x](int e){ return e < x; });
// ...
}
There are other changes, but which less invalidate C++03 way to code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With