More on Getting the Number of Array Elements

In a previous post, I discussed a safer way to get the number of elements in a C++ array.  I mentioned that the countof() macro doesn’t work with local types (i.e. types defined inside a function definition).   I just realized that the macro also fails to work with anonymous types under certain circumstances.  To…

3

Programming in XSLT!

Not so long ago, I posted a programming challenge, and received solutions in many different languages.  Just when I thought people had forgot about this, I got this one from Anton Triest.  It was written in a programming language called … (surprise) XSLT! Ask not what you can do in XSLT; ask what you cannot do…

1

Generalize Smart Pointers in C++

After programming in C++ for a while, you will inevitably be introduced to the concept of “smart pointers” (or you will discover them on your own).  These are pointers that know to automatically release the objects they point to when they (the pointers) are destructed.  They have proved quite handy in avoiding memory leaks.  …

10

Using template specialization in C++

We all know that C++ templates can be used to write generic code, e.g.   template <typename T> class Array { … };   Then we can use the same template to generate code for different template parameters.  This is called instantiation of the template.  e.g.   Array<int> x; Array<string> y;   However, sometimes we…

0

Using C++ Member Function Pointers

I don’t know about you, but the C++ syntax for member function pointers always eludes me.  Every time I would spend half an hour or more deciphering MSDN to get the exact syntax, only to completely forget it the next time.  Oops.   I can think of three reasons why this is happening:   The…

1

How Would You Get the Count of an Array in C++?

The question is simple: given a C++ array (e.g. x as in int x[10]), how would you get the number of elements in it?   An obvious solution is the following macro (definition 1):   #define countof( array ) ( sizeof( array )/sizeof( array[0] ) )   I cannot say this isn’t correct, because it…

0

Top reasons for failing to download Visual Studio Express beta 1

As you might know, now you can download Visual Studio express SKU’s from here for free. Since the release last Monday, we have seen that some users failed to download this product.  The top reasons include: 1. The user cancelled the download. Please be reminded that you are downloading a large product, for example, the documentation…

7

Improve Longhorn code quality

Starting the coming Monday (July 12, 2004), I will be working for the Windows devision instead of Visual Studio.  My new team is focusing on improving the quality of the Longhorn code base.  I might write more about it once I get an idea on what it is really like there. I would love to…

3

Welcome, Aaron!

I’m glad to see Aaron Stebner started blogging about setup (installer). Before Aaron switched team, he was a QA lead in the VS / .NET setup team, which I’m working for.  He was a great resource then.  Looks like his posts will be a new valuable source of information for my work.  I expect them…

0

How Would You Get the Count of an Array in C++?

The question is simple: given a C++ array (e.g. x as in int x[10]), how would you get the number of elements in it?   An obvious solution is the following macro (definition 1):   #define countof( array ) ( sizeof( array )/sizeof( array[0] ) )   I cannot say this isn’t correct, because it…

4