C++11: nullptr

In C and C++ we use the preprocessor macro NULL to say a pointer is not pointing to anywhere right now. The problem with NULL is that underneath it is just a plain 0. Consider the problem looking at this code excerpt: If you try to compile it using g++ 4.6, you will get something… Continue reading C++11: nullptr


C++11: Range-based for loop

In C++03, if I have a vector and want to show its elements, I could do something like this: That method will be useful to show any collection that has a begin() and an end() and an iterator with an operator++(int), an operator!=() and an operator*() properly implemented. C++0x provides us a very useful range-based… Continue reading C++11: Range-based for loop

Java: Writing a Windows Forms application using Java

I was playing around with IKVM.NET (www.ikvm.net) and I found it very very interesting. IKVM.NET is a Java Virtual Machine implemented on top of .NET; and though this is already kind of weird, the most interesting thing is that inside IKVM, the Java objects of your Java application are first class objects of the CLR.… Continue reading Java: Writing a Windows Forms application using Java

C++: The curiously recurring template pattern

Let's consider the following class: This class will be useful as the base class for implementing several specialized writers (a file writer and a console writer come to my mind right now), for instance: Nice, isn't it? We can use the Writer::write() method to write on any kind of media depending on the subclass we… Continue reading C++: The curiously recurring template pattern

C++: Inheritance on template specialization

When you implement something like: You are saying the C++ compiler: "Please, use the first template for all the MyClass<T> instances with any T except for the MyClass<T> instances where T = char". The problem I see with this approach is that you must provide full implementations for the template and for the <char> specialization… Continue reading C++: Inheritance on template specialization