With a bit of fiddeling you can use every kind of bracket to basically make function calls in c++
Here are the links to the snippets, all compile and run
Rust: https://godbolt.org/z/bM3d7bG14
With a bit of fiddeling you can use every kind of bracket to basically make function calls in c++
Here are the links to the snippets, all compile and run
Rust: https://godbolt.org/z/bM3d7bG14
There are lots of ways to write C++ code that looks perfectly reasonable but introduces horrible undefined behaviour. You need to be aware of lots of edge cases all the time and you will still make mistakes that can introduce difficult to trace bugs. One of my personal favourites is object slicing.
class A { int foo; }; class B : public A { int bar; }; B b; A a = b;Looks OK? Well,
anow only contains theApart of the object. The fieldbaris lost in the assignment. There are reasons for this behaviour but its a sharp edge nonetheless.These kinds of problems are numerous and you have to keep them in mind while programming C++. Some people don’t mind it but many do. Static analysis tools that can catch many of these errors exist, but I understand people who say they don’t want to deal with that and rather use a language where these kind of errors are not possible. Personally, I would also discourage people from starting new C++ projects today if they can avoid it.