So I bought "C++ for Dummies" the other day. I've always been interested in programming, and taught myself RealBasic using SilverCreator when I was 11, and was into that for a year or so. Anyways, I signed up for a computer programming class this year, but I'm impatient and wanted to get a head start over summer, thus buying "for Dummies" book. I checked and made sure it was Mac compatible before I bought it, but I soon found the program it wanted me to use, "codeblocks" was uber-lame(super slow, and wouldn't let me use the spacebar). So I installed XCode off my Leopard disc, and transferred the day's worth of experience/plagiarism, a program that converts Fahrenheit to Celsius. Over into XCode. Some of the commands that the Dummy(hehe, no pun, seriously) book that were very vital to basic coding showed an error on XCode. But I don't really care about the errors now.
That was all just to brief you so you could give me more important advice: What programming language/environment should I be following for a noob like me who has very little, but some experience coding, has a Power PC iMac, but access to a very slow PC, would like to debug/contribute to open-source cross-platform games(yes, Lugaru) and software, and maybe even go on to develop games/software one day? Is C++ the right choice? Give me your opinions.
Thanks,
Healey
EDIT: Here is the link to the forums where I am asking specific help on the coding errors, if you think you could help with that-http://www.mac-forums.com/forums/os-x-d ... ost1063647
Give advice to me- a noobie programmer
Re: Give advice to me- a noobie programmer
I guess you can use a c++ compiler, but I think it is best to start with C only code. (i.e. use fprintf() instead of std::cout << ) why? because you should never learn C++ wondering why << is an overloaded operator or what an overloaded operator even is.
You should try to learn these topics in depth before moving on. The basic data types (except pointers) and the operators, then loop logic and then functions.
But if you wan't your programs to be able to display and input text (so you can test your programs) then you will have to
#include stdio.h
or
#include <stdio.h>
and learn to use the printf() and scanf() functions right off the bat. And even then you probably don't want to use arrays until you have come to understand the topic mentioned just below.
Finally, the one data type you should learn before moving on to cool C++ stuff is pointers. All variables you will have been working with so far, will have been directly accessing memory and all your parameter passing would have been by value. But it is critical that you understand what a pointer is, because it is essential for distinguishing passing by value and passing by reference. And when you have many multiple variables and functions going on, you definitely want to keep track of what you have passed by value, and what you have passed by reference.
Pointers are fun, but more importantly pointers save you memory and they let you use arrays in C.
Once you know these things then you can start to really utilize all the tool provided by the basic c libraries
http://www.cplusplus.com/reference/clibrary/
malloc and free are fun ones for wasting (or leaking) a lot of memory and assisting you in causing segfaults.
and there may be other fun things to learn before finally examining C++ features with a closer look.
Of course, cout and cin are just such darn convenient parts of the C++ cstdio library so if you insist on using it instead of printf() and scanf() just remember this
<< and >> are not being used as their default functionality. They are infact the bitwise shift operators
http://en.wikipedia.org/wiki/Bitwise_op ... B_and_Java
They are however being used completely differently because they are overloaded operators
http://en.wikipedia.org/wiki/Overloaded_operator
that work on instance of stream classes as one of their parameters. cin and cout are special instances of the stream classes, for which the magic of the iostream class has made writing and reading from the console possible.
Oh and to answer your question about your errors on the other thread.
notice how at the top I used cout like this "std::cout << "
That is because of a thing called namespaces in C++. cout does not mean anything in the global namespace (which you are in by default), therefore you have to either pull the std namespace into the current namespace by typing this line at the top (after #includes)
"using namespace std"
or by specifying the namespace by preceding every use of these names with
"std::"
I prefer the second because, you never know when you could accidentally create a name that conflicts with std.
http://www.cprogramming.com/tutorial/namespaces.html
Also... you forgot some semicolons... DAMN YOU SEMICOLONS!!! why can't I ever keep track of you guys.
You should try to learn these topics in depth before moving on. The basic data types (except pointers) and the operators, then loop logic and then functions.
But if you wan't your programs to be able to display and input text (so you can test your programs) then you will have to
#include stdio.h
or
#include <stdio.h>
and learn to use the printf() and scanf() functions right off the bat. And even then you probably don't want to use arrays until you have come to understand the topic mentioned just below.
Finally, the one data type you should learn before moving on to cool C++ stuff is pointers. All variables you will have been working with so far, will have been directly accessing memory and all your parameter passing would have been by value. But it is critical that you understand what a pointer is, because it is essential for distinguishing passing by value and passing by reference. And when you have many multiple variables and functions going on, you definitely want to keep track of what you have passed by value, and what you have passed by reference.
Pointers are fun, but more importantly pointers save you memory and they let you use arrays in C.
Once you know these things then you can start to really utilize all the tool provided by the basic c libraries
http://www.cplusplus.com/reference/clibrary/
malloc and free are fun ones for wasting (or leaking) a lot of memory and assisting you in causing segfaults.
and there may be other fun things to learn before finally examining C++ features with a closer look.
Of course, cout and cin are just such darn convenient parts of the C++ cstdio library so if you insist on using it instead of printf() and scanf() just remember this
<< and >> are not being used as their default functionality. They are infact the bitwise shift operators
http://en.wikipedia.org/wiki/Bitwise_op ... B_and_Java
They are however being used completely differently because they are overloaded operators
http://en.wikipedia.org/wiki/Overloaded_operator
that work on instance of stream classes as one of their parameters. cin and cout are special instances of the stream classes, for which the magic of the iostream class has made writing and reading from the console possible.
Oh and to answer your question about your errors on the other thread.
notice how at the top I used cout like this "std::cout << "
That is because of a thing called namespaces in C++. cout does not mean anything in the global namespace (which you are in by default), therefore you have to either pull the std namespace into the current namespace by typing this line at the top (after #includes)
"using namespace std"
or by specifying the namespace by preceding every use of these names with
"std::"
I prefer the second because, you never know when you could accidentally create a name that conflicts with std.
http://www.cprogramming.com/tutorial/namespaces.html
Also... you forgot some semicolons... DAMN YOU SEMICOLONS!!! why can't I ever keep track of you guys.
-
Healey
Re: Give advice to me- a noobie programmer
Thanks a lot for the feedback.
And my program works now. Thanks much for that.
Though my head exploded when I read this.Skomakar'n wrote:Why are you telling him to use standard C IO and malloc/free?
And my program works now. Thanks much for that.