Equivalent of c# 'as' command in c++?
- by Sam
In c# you can use as to convert a type or get null:
Object o = Whatever();
String s = o as String;
Is there a similar easy way to achieve this in c++? I'm using Visual Studio 2010, if thats important.
[update] Remember, there is a very important difference between casting and using as. Casting (at least in c#) will throw an exception if the type does not match:
Object o = null;
String s = (String)o; // will crash.