In C#, I like the var
keyword for situations like this:
var myList = new List<MyType>();
Is there any equivalent in C++/CLI, or do I have to repeat the type name everytime just like this:
List<MyType ^>^ myList = gcnew List<MyType ^>();
Could not find an explicit statement in the docs or by Google so far. I am using Visual Studio 2008.
Addendum from 2022: as the accepted answer states correctly, today there is the auto
keyword. We are now using this for years, and it works flawlessly for both managed and unmanaged types.
No, there is no direct alternative for in in C, and one cannot exist.
There is nothing equivalent to classes . Its a totally different paradigm. You can use structures in C. Have to code accordingly to make structures do the job.
There is no string type in C . You have to use char arrays.
The best thing I can do is using var , but the var keyword doesn't exist in C.
In Visual Studio 2008 there is no such equivalent. However with Visual Studio 2010 you can use the auto
keyword to implement var
like semantics in C++. I know this works with non-managed C++ and I'm fairly certain it works for C++/CLI as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With