A curated list of awkward C++ (or C) syntax, standard library, ways of doing things, best practices, etc.
Even learning and using C++ for years, you would definitely have times when C++ surprises you with weird looking syntax that you never used, simple ways to do complicating things you never expect or hard to find bugs that you encounter again and again. This is a curated list of these sorts of things. You can read one everyday and learn C++ better.
struct B { virtual void foo(); };
struct D : B {
void foo() override;
void bar() {
B::foo(); // This is commonly used to call B::foo() (static dispatch)
}
};
int main() {
D x;
B& b = x;
b.foo(); // calls D::foo (virtual dispatch)
b.B::foo(); // Do you know this syntax before? calls B::foo (static dispatch)
}
#include <iomanip>
#include <iostream>
int main() {
std::cout << std::setprecision(17) << 0.1 + 0.2; // -> 0.30000000000000004
}