Author
Topic: best program to learn C++? (Read 15754 times)

Hello, I've got alot of experience programming robots using BASIC but I want to learn C++. Not just for robots, but to make a simple program. Does anyone have any suggestions what compiling program to get for noobs?

I use Bloodshed Dev-C++ and it works great for me, although I am still a total noobie at it. That should work fine for windows, but if your running a *nix operating system or a mac OS then i think you will need a different one.

The standard AVR tools contain a C++ compiler as well as the C compiler. See my posting in the member forums for a C++ library to help you out. But if you need to learn C++ from scratch then consult Google, books etc etc.

Probably one of the best ways to learn C++ is on a Linux/Unix system at the command prompt. If you have a Linux/Unix system handy, you can get quite far with very little effort. Unless you're familiar with Linux/Unix, building a system just to learn C++ is probably not the best use of your time.

For the Windows oriented person, Microsoft has free versions of their Visual Studio languages, C++ is here. Its adherence to the C++ standards and standard libraries is at times questionable, but for your purposes it'll do just fine. Just realize when you move from a PC to an MCU like the AVR series, that Microsoft uses a superset of the standard C++ libraries, and WinAVR, because of memory and processor constraints, uses a subset of the standard C++ libraries. Not everything you can do on a PC is going to work on an AVR.

I find programming MCUs much more difficult because you constantly have to be aware of the data space usage, program size, and algorithm optimization. All of those concerns/pitfalls make it huge effort to spit out your first "blink" program if you're still struggling with the language. For that reason, it might be better to learn C++ on a PC first, then jump into MCU programming. Hopefully by then WinAVR will properly support C++.

Also, as Webbot suggested, get a book. A good one. Something you can use as a reference. It's been years since I bought a book on C++, but the one I bought and learned from is "The C++ Programming Language" by Bjarne Stroustrup. Not sure its even still in print, or if the C++ standards have deprecated its contents.

(haha...cool...I just pulled the book off my shelf and I must have been using the original receipt as a bookmark. It was purchased on 6/26/1989 at 4:53pm for $33.75. How it stayed in the book for that long with that much use, I have no idea.)

For the Windows oriented person, Microsoft has free versions of their Visual Studio languages, C++ is here. Its adherence to the C++ standards and standard libraries is at times questionable, but for your purposes it'll do just fine.

Thanks, thats more of what i'm looking for. (2 hr and 36min to download though , time to take a nap )

Quote

haha...cool...I just pulled the book off my shelf and I must have been using the original receipt as a bookmark. It was purchased on 6/26/1989 at 4:53pm for $33.75. How it stayed in the book for that long with that much use, I have no idea.)

lol

I first want to make simple logic programs on my PC for starters, because i might have to program a PLC for a machine at work. However, I'd like to also program robots later in C++ rather than BASIC

Hi,I don't think you need to buy VS Studio Pro just to learn C++. You will not be able to write programs for robots in VS - at least not for the cheap ones which use microcontrollers, such as Atmel or PIC. To learn C++ the free (Express) edition of Visual C++ will do fine. Even better, I'd first buy a book or find a good tutorial on the internet and then use the program which my learning text uses. The book may even include CD with Visual C++ or other development environment, so no need to download for 3 hours

I know Code Warrior from programing Freescale microcontrollers HC08. There are versions of this IDE which can compile code for many microcontrollers, DSPs and I guess also for Windows which you used in your courses. For a start you should probably write simple Win32 "Console applications" - that's exe file which displays black command prompt window when you start it- In this type of program you can easily output results from your programu using "printf" or "cout". Don't get into any GUI stuff if you intend to use C++ for programming microcontrollers, you will not need it and it's too complex. The advantage of Code Warrior is that you could stick with the same environment when moving from Windows programs to microcontroller, but MS Visual Studio is much nicer to work with - I'd say it's the standard of development IDE, the other IDEs are something like a year or 2 behing it... I know some people will disagree

Thanks for the posts guys . I think buying a book for starters with a CD is probably my best bet. Any idea what type and where to buy a good one (preferabley at a well-known books store or something ) I've googled it and i get a lot, theres got to be one thats the best )

For a start you should probably write simple Win32 "Console applications" - that's exe file which displays black command prompt window when you start it- In this type of program you can easily output results from your programu using "printf" or "cout". Don't get into any GUI stuff if you intend to use C++ for programming microcontrollers, you will not need it and it's too complex.

Good point dolinay. I was heading back to this thread to say this exact thing. Stay with Win32 console apps because that's more like what the MCU programming environment is like.

Ok Ive just download Dev-C++ and I'm trying out a program that can take the average of three numbers. However, I just noticed something when i had compiling errors on a code thats i saw work on You-tube. And then i happened, i have Vista on my laptop and the requirments didn't say if they support it. Any body have any trouble with vista or even try it?

Ok Ive just download Dev-C++ and I'm trying out a program that can take the average of three numbers. However, I just noticed something when i had compiling errors on a code thats i saw work on You-tube. And then i happened, i have Vista on my laptop and the requirments didn't say if they support it. Any body have any trouble with vista or even try it?

Bane

I don't know anything to help you there but all I can say is C/C++ can be tough to learn. Seriously start out with a simple "hello world" C program see if you still get your errors. It might be just things in the compiler that needs to be configured properly.

I would recommend starting off slow learn C basics. Loops will be similar to stuff you've done in Basic. Learn how C works, syntax, logic, functions. That alone will help you quite a bit. There are more things like structs and pointers that you want to learn but aren't 100% necessary from what I've played around with in microcontrollers. C++ just builds on C and takes things to a whole new level and a slightly different way of thinking.

Sorta, there are ton of settings and I've never used that compiler. Some of the settings involve telling to tell the compiler where to set the displaying of warnings/levels at. It might be compiling just fine and its just shooting a ton of warnings flags.

I don't know about the rest of you guys, but I'm a veteran programmer, especially in C++, and I think the best way to learn C++ is to pick up a copy of Beginning Programming for Dummies. It's how I learned (programming in general and C++). I don't recommend getting C++ for dummies because the book is harder to understand and most of it is covered in Beginning Programming for dummies.

I use code::blocks, which is all i want. it has mingw with it, and i found a distro that included avrgcc.it has an avr project template if you really want it, so you can compile and manage both your pc software and your avr software from the same IDE.

Logged

Check out my homepage for in depth tutorials on microcontrollers and electronics.

I was just thinking about making a C++ program that can factor a polynomial. I was thinking i might actually pretty easy.......maybe . I could use the quadratic formula and hopefully be able to even get imaginary answers out of it. Sound pretty cool?

Any idea how to enter the ax^2+bx+c without entering it in a different line every time?

I was just thinking about making a C++ program that can factor a polynomial. I was thinking i might actually pretty easy.......maybe . I could use the quadratic formula and hopefully be able to even get imaginary answers out of it. Sound pretty cool?

Any idea how to enter the ax^2+bx+c without entering it in a different line every time?

You can do a for loop into the char array to find out if you have a plus sign. Note that location.So from the beginning of the array (0) to that delimiter location (4) minus one you have one token. (ax^2)

Using that found plus sign location you loop through the array again looking for the next plus sign.From the first plus sign (4) plus one, to the last plus sign (7) minus one you have the next token. (bx)

From the last plus sign loop to find NULL.From the second plus sign (7) plus one, to the NULL (9) minus one you have the last token. (c)

exactly. C++ is crap. that's why it is the choice of major game design companies and the assumed language in almost any openGL tutorial, the language in which the php interpreter is programmed, the language on which most linux distros and the attached software comes programmed in. Anot to mention, most of the pseudocode out there follows a C++ structure (curly braces, pointer and object operators ).

So, I guess that so many people use it just because they think it's good. They're wrong. Use Visual Basic. 3, if possible. If not, 2, or Qbasic. That's what Torvalds used to write its kernel.