Advice needed re: learning C++

What are good references/tutorials/books on C++, especially as used for programming AVRs and other MCUs?

I'm pretty new at this language and find it a little cryptic at times...

I program VB/VBA, and I am an EE by trade. I know electronics and RF, now need a supplement of C++.

Suggestions appreciated.

Just do it! Best way to learn. I am an EE also. Can be ugly code at times, gets better as you go. I look at stuff I wrote in August when I started vs now, huge difference.
Start with some simple stuff, and build up.

"Just do it!" Yes, that's my usual approach...

I've been able to get a lot of the small stuff and concepts down, my project now is a PID temp controller for a kiln...so I am finding out I need to know a whole lot more about C++!

Rather then reading reference manuals, I found I was picking up C/C++ faster by just reading as many of the existing example sketches as possible. Many are very simple and great for first learning, later one can even open up and read the many arduino 'core' library files to see how low level programming is used to manipulate the AVRs many registers. Make no mistake, C/C++ can be a write only language if the programmer wants to be very terse and obscure on how they perform tasks, but it's also possible to write and understand very simple and clear functions, the Arduino platform was based on developing easy to use and understand functions like digitalRead(pin#); rather then the low level commands needed to read a I/O port register and pick out the bit of interest.

With your background you will have little problem picking it up. And the AVR type applications are so down to earth most times, you don't get burdened by having to understand all the Windows API before you can even start writing simple programs.

Good luck and enjoy your Arduino, better then sliced bread.

Lefty

You could try the PID libary
http://www.arduino.cc/playground/Code/PIDLibrary

I have started converting the sparkfun PIC C code for their oven controller into something arduino based. Sounds like a good application for PID also.
Was going well until I got to the display, then I got a little sidetracked, and we bought some furniture so we spent the last couple nights cleaning up the living room, so I need to get back on track with that.

"better then sliced bread" and like sliced bread, younger than Hugh Hefner 8)

If I had some time, I would learn the language, which is totally different from using it for MCU. That would be like learning French and working in a French restaurant. You learn the language first, then use the language to do stuff or learn more things. I suggest C++ from the ground up by Herb Schildt. You're EE so you will appreciate his clarity and logic in his book. MCU can be programmed in a number of languages besides C.

I learned plain ol' C first, I think Kernighan & Ritchie is just about as well-written and concise a book can be.

I'm fairly new to C++, but know a bit of other OO stuff, so feeling my way along in the dark so far hasn't been too bad. My daughter tells me that Stroustrup's is one of the go-to books for C++, will no doubt pick it up when I have time.

A whole lot can be done with Arduino without having to develop classes, etc.

You can certainly feel your way with C++, especially because arduino has no multi-tasking so resources are all available to the code for that matter. I only need to write constructor but no need for copy constructor or destructor, which are there specifically to deal with resource allocation and release. You also don't do lots of polymorphism except for just compiler lever. There's not much memory for that either. So it boils down to me that encapsulation was most important and not much inheritance. So a quick dip into C++ can get you started, only if you already know C.

Reminds me of a Farside cartoon:
What software engineers say "I only need to write constructor but no need for copy constructor or destructor, which are there specifically to deal with resource allocation and release. You also don't do lots of polymorphism except for just compiler lever. There's not much memory for that either. So it boils down to me that encapsulation was most important and not much inheritance. "

What hardware engineers hear "You can certainly feel your way with C++, ... only if you already know C" :wink: 8)

So a quick dip into C++ can get you started, only if you already know C.

Well one fallout of the Arduino's popularity, for good or bad, is that there is and will continue to be thousands and thousands of new people learning to program their Arduino boards and not knowing what parts they are learning are C and what parts are C++. Not sure if that is good or bad, just different from the more traditional learning transition I would think? None of the Arduino documentation seems to deal with this, and it doesn't seem to matter much to the goal of learning to program ones Arduino.

Lefty

I certainly couldn't say which part was which.
After having done BASIC back in high school, and FORTRAN and some Z80 assembly in college, and exposure to other stuff as well that I couldn't even tell you the names of its been so long, I didn't find Arduino too hard to figure out for the mostly basic stuff I do now. For me it comes down more to understanding what external devices need.

retrolefty:

So a quick dip into C++ can get you started, only if you already know C.

Well one fallout of the Arduino's popularity, for good or bad, is that there is and will continue to be thousands and thousands of new people learning to program their Arduino boards and not knowing what parts they are learning are C and what parts are C++. Not sure if that is good or bad, just different from the more traditional learning transition I would think? None of the Arduino documentation seems to deal with this, and it doesn't seem to matter much to the goal of learning to program ones Arduino.

Lefty

Traditional programming learning should be changed! I learned BASIC at the right age, 7. So everything else was almost natural when I taught myself. On the other hand, the approach to teaching programming language should be the same as teaching any humanly language, start from reading simple but well written programs over and over before learning to write.

"start from reading simple" >> but well written programs<< "
Well I would say that includes comments too, and rules out a lot of the things that are posted arund here.

If anyone is in a situation like me, check out "Accelerated C++" by Koenig & Moo. I've only been using it for a couple of days, but it seems like just the ticket for someone with a little programming (other than C) under their belt already, just needing to understand C++.

I bought a few months ago a C++ book. It call " C++ for Dummies" by Stephen R. Davis It also include a CD-ROM of a IDE to program C++. It call "Code:Block" GNU C++ compiler. And I also bought recently "Sams Teach Yourself C++ in One Hour a Day" No compiler...About the Ardino, I just receive my order today the book "Ardiuno Cookbook" Also bought recently a book call "The Art of Assembly Language". I have a EET background. I just catch up my knowledge here.

Here the store I bought theses books. http://www.chapters.indigo.ca/home/

I know, some of them are NOT CHEAP !!! :stuck_out_tongue: But they are worth it.