Geeks With Blogs
Robert Bernstein's Blog Adventures in Windows, .NET, and C++ C++
C++ Casting Operators
I often get confused about the different types of C++ casts: dynamic_cast can be used for "upcasting" or "downcasting" Upcasting: A* pA = dynamic_cast<A*>(pB) when B inherits from A Downcasting: B* pB = dynamic_cast<B*>(pA) when B inherits from A static_cast static_cast conversions are not as safe as dynamic_cast conversions, because static_cast does no run-time type check, while dynamic_cast does. A dynamic_cast to an ambiguous pointer will fail, while a static_cast returns as if nothing ......

Posted On Wednesday, October 6, 2010 3:41 PM

Change the Default VS2010 Start Page "Language"
When you first run Visual Studio 2010 (VS2010), it asks you to select a profile (e.g. C#, C++). This determines the Start Page displayed when VS2010 starts. Once you pick this, there appears to be no easy way to change your selection (at least none that I've found). To see which start pages are available to you, look in the following directory: 32-bit Windows: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\StartPages\en 64-bit Windows: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\StartPages\en ......

Posted On Friday, September 17, 2010 2:04 PM

Integrate the Windows SDK v7.1 with VS2010
Final Solution: I figured it out! Open your project in VS2010, select the Project menu and choose Properties..., and click the dropdown next to Platform Toolset. You can select between v100 (VS2010), v90 (VS2008), and Windows7.1SDK. Select the 7.1 SDK and click OK. Now you're all set. Note that you can use v90 to build apps that compile for older versions of Windows as long as you have VS2008 already installed on your machine. --------- The information below is just kept to remind me what I did. ......

Posted On Friday, September 17, 2010 1:34 PM

C++ Array Size Function
I'm dividing my time between the .NET world and developing in C++ again, so I'm going to be posting some handy snippets here. Rather than using: sizeof(array) / sizeof(element) to determine the size of an array, we can use a template to accomplish this. // // A handy two-line array_size() template function // #include <cstdlib> #include <iostream> using namespace std; // Uses template type induction to // discover the size of an array // so that you don't have to use sizeof(array)/sizeof(element) ......

Posted On Wednesday, June 30, 2010 10:35 AM

Copyright © Rob | Powered by: