Hi Im new here. Need some advice
Hi everyone. Im new on this forum and in C++.
Tomorrow Im going to buy some C++ books and I hope they helps me a lot..
Programming is my hobby so I desided to start with simple games. What do you recommend to me to try first?
I know some basics like type of vars, statements, arrays etc. But today I was read something about pointers and it seems like new to me.
P.S What a lovely forum :p I like that tag feature -.-
P.P.S In addition, Im going to take care on my english grammar and find approporiate book for it :P Sorry, Im not living in england or us and usually Im using english only for reading :\
You don't need to learn pointers on the first day.
I guess pointers are confusing because they have to do with what's going on inside the computer.
All variables reside at a particular physical memory location (address). Most of the time you don't need to know their address. You only need to know the variable's name.
A pointer is a variable that holds the address of another variable. So, it "points to" a variable. Again, you normally don't need to know the addresses... you only need to know the name of the pointer, and the name of the variable that it points to.
My standard homework analogy:
Bob has the homework answers. Bob is a normal variable. If you know that Bob has the answers, you can directly ask him..
If Sally doesn't know the answers but she knows where Bob lives, she's a pointer.
If don't know Bob, but you know Sally, you can use what is called dereferencing and tell Sally "Go get the answer". (You dereference simply by writing *Sally.)
If you forget to dereference, Sally will give you Bob's address... This is NOT what you want!
rockdj,
You will study functions before you study pointers. Everything in C++ is done with functions. You will learn that a function can return only one value. For example, a function can return a single character, but not a full sentence (i.e. a string variable). A single pointer can give your function access to the whole string.