Geeks With Blogs

News Bob Taco Industries is an ISV focused on game and app development for Microsoft platforms headed up by Michael B. McLaughlin. Mike is a Microsoft Visual C++ MVP (previously an XNA/DirectX MVP from 2011-2013), a developer, a writer, a consultant, and a retired lawyer. If you're a developer who is just getting started, consider checking out the BTI website's section for developers for links to code samples and other helpful sites.
Bob Taco Industries Blogging Division

Last updated: 2012-02-14

This is a big post – over 12200 16600 words – and so I’ve decided to make it available as a PDF download, which you can get here:

http://www.bobtacoindustries.com/Content/Devs/CsToCpp-ASomewhatShortGuide.pdf

It has bookmarks for easier navigation along with a Table of Contents and page numbers.

I expect that I will revise this from time to time and welcome any suggestions, feedback, and (especially) corrections. If so I will update the Last updated field at the top and will create a revised PDF as well. I hope this proves useful.

Update: I realized when looking at stats the other day that this post was so big that it wasn’t going through to many people’s RSS feeds (including my own!). So I stripped out the text and have decided just to keep it as a PDF link.

Updates and Changes:

2012-02-14

New sections:

  • Namespaces
  • enums subheading under Fundamental types
  • Functions
  • A brief word on the volatile keyword
  • Casting values
  • nullptr subheading under Pointers
  • Lambda expressions

Significant changes:

  • Added discussion of cstdint header to Fundamental types
  • Touched up some language and added a brief note on “mixins” to Multiple inheritance
  • Added subheadings to C++ constructors; also revised its code sample
  • Added a note about non-string uses of the ‘char’ type to Strings

There were many other miscellaneous edits made. I incorporated much of the great feedback I’ve received in the comments. I did not end up moving the Pointers section this time but have not ruled it out either. I’m on the fence about it because, to me, modern C++ is all about clean, safe code with automatic storage duration objects and C++ Standard Library container types. Pointers are still a part of C++ and likely always will be. But I’m not convinced that they belong right up front. I need to re-read the document through from beginning to end before I make a decision on that, I guess.

Most of the things I wanted to add this time around are in the document now. I’m considering a section on multi-threading but that will have to wait for another update. Once VS11’s ranged for loop support is released, I’ll be adding a section on that. I would like to make the templates discussion a lot more in depth at some point but that’s something for another time.

The link above has not changed; the new version is there now and has subsumed the old one. I’ll be posting this as a new blog post as well so if you see it twice, that’s why.

Posted on Thursday, February 2, 2012 8:45 AM C# , C++ | Back to top


Comments on this post: C# to C++ – A Somewhat Short Guide

# re: C# to C++ – A Somewhat Short Guide
Requesting Gravatar...
This is great info, thank you so much for compiling and sharing it.

I would suggest a better ordering of your topics however. You talk about pointers and references quite often but don't actually get to them until much later.
Left by Bob on Feb 03, 2012 12:40 PM

# re: C# to C++ – A Somewhat Short Guide
Requesting Gravatar...
Thanks! I'll work on re-ordering for the next version.
Left by MikeBMcL on Feb 03, 2012 1:27 PM

# re: C# to C++ – A Somewhat Short Guide
Requesting Gravatar...
Thank you for sharing this. You ROCK!
Left by Morten on Feb 03, 2012 5:43 PM

# re: C# to C++ – A Somewhat Short Guide
Requesting Gravatar...
Thanks a lot! This is likely what I needed...
Now, time for a very first "hello world" exercise :p.
Left by Alejandro on Feb 04, 2012 8:15 PM

# re: C# to C++ – A Somewhat Short Guide
Requesting Gravatar...
Great work! Some bugs though (posting for review on e.g. [comp.lang.c++] could be a good idea for later such works?). Anticipating that posting a comment here would not be trouble-free, I copied what I wrote over to Notepad before submitting. And well that I did! The submission apparently just disappeared into the Big Bit Bucket In The Sky, so I put it on Pastebin instead: http://pastebin.com/ZZEjgcTq
Left by Alf P. Steinbach on Feb 10, 2012 8:03 PM

# re: C# to C++ – A Somewhat Short Guide
Requesting Gravatar...
Alf: Thanks for the great feedback! I'm going to be readying the first update this weekend and I definitely appreciate the great suggestions and corrections!
Left by MikeBMcL on Feb 10, 2012 8:13 PM

# re: C# to C++ – A Somewhat Short Guide
Requesting Gravatar...
Awesome reference materials in this article, thanks so much!
Left by Jayson Knight on Feb 11, 2012 3:35 PM

# re: C# to C++ – A Somewhat Short Guide
Requesting Gravatar...
Nice Artcle! Looking forward for more similar articles
Left by Sriivasa on Feb 12, 2012 2:26 AM

# re: C# to C++ – A Somewhat Short Guide
Requesting Gravatar...
Wow, exactly what I was looking for!
I wanted to learn a Bit C++l but didn't feel like taking One of these Books for absolute Beginners, because I knew C# already. Thanks!
Left by Niklas Rother on Feb 15, 2012 11:22 AM

# re: C# to C++ – A Somewhat Short Guide
Requesting Gravatar...
Just a quick note -- when you mention storage duration (and even before you warn against raw "new") it might be a good idea to emphasize that using automatic storage duration is the usual way of doing things in C++ and a good default choice. A common mistake of programmers transitioning from C# or Java is to (ab)use the "new" keyword for object(s) creation in cases where there's really no reason to use the free store.
So, chances are, that if a C# or Java programmer is thinking of typing:
SomeClass * object = new SomeClass; // don't do this if you don't need to
he should really be typing
SomeClass object; // do this

Generally, free store allocation is expensive compared to the stack-stored automatic variables, so it should be avoided whenever possible (and, as you mentioned, there's also the issue of memory leaks and having to use the smart ptrs.).

Regarding terminology, this might also be good to refer to: http://www.gotw.ca/gotw/009.htm

HTH!

Left by MD on Feb 16, 2012 11:16 AM

Comments have been closed on this topic.
Copyright © Michael B. McLaughlin | Powered by: GeeksWithBlogs.net | Join free