Do the parentheses after the type name make a difference with new?

If ‘Test’ is an ordinary class, is there any difference between: Test* test = new Test; and Test* test = new Test(); 7 s 7 Let’s get pedantic, because there are differences that can actually affect your code’s behavior. Much of the following is taken from comments made to an “Old New Thing” article. Sometimes … Read more

What is the difference between ‘typedef’ and ‘using’ in C++11?

I know that in C++11 we can now use using to write type alias, like typedefs: typedef int MyInt; Is, from what I understand, equivalent to: using MyInt = int; And that new syntax emerged from the effort to have a way to express “template typedef”: template< class T > using MyType = AnotherType< T, … Read more

What are POD types in C++?

I’ve come across this term POD-type a few times. What does it mean? 9 s 9 POD stands for Plain Old Data – that is, a class (whether defined with the keyword struct or the keyword class) without constructors, destructors and virtual members functions. Wikipedia’s article on POD goes into a bit more detail and … Read more

Where and why do I have to put the “template” and “typename” keywords?

In templates, where and why do I have to put typename and template on dependent names? What exactly are dependent names anyway? I have the following code: template <typename T, typename Tail> // Tail will be a UnionNode too. struct UnionNode : public Tail { // … template<typename U> struct inUnion { // Q: where … Read more

Why do we need virtual functions in C++?

I’m learning C++ and I’m just getting into virtual functions. From what I’ve read (in the book and online), virtual functions are functions in the base class that you can override in derived classes. But earlier in the book, when learning about basic inheritance, I was able to override base functions in derived classes without … Read more

What are rvalues, lvalues, xvalues, glvalues, and prvalues?

In C++03, an expression is either an rvalue or an lvalue. In C++11, an expression can be an: rvalue lvalue xvalue glvalue prvalue Two categories have become five categories. What are these new categories of expressions? How do these new categories relate to the existing rvalue and lvalue categories? Are the rvalue and lvalue categories … Read more

Compiling an application for use in highly radioactive environments

We are compiling an embedded C++ application that is deployed in a shielded device in an environment bombarded with ionizing radiation. We are using GCC and cross-compiling for ARM. When deployed, our application generates some erroneous data and crashes more often than we would like. The hardware is designed for this environment, and our application … Read more