project

Hi guys,

my question is a short one: how did you learn c++ and how long it did take to be a decent programer with the language?

I did develop lots and lots of skills in the late days, from video tutorials which were very very usefull, but there are some stuff that aren't clear...

What things would you recommend as first projects?

regards,
I'm currently learning from Programming Principles and Practice by Bjarne Stroustrup, which is a great book imo.

As for projects, I'm currently trying to get a program to solve Sudoku puzzles, which is a challenge but I'm conviced it's do-able. :)
Oh my! :o

That's something. I am looking up the book now... That sudoku solver seems to be complicated... My dream would be to create some 3d graphic related thing... but that seems to be far. haha :)
By your sudoku solver, which would be too complicated for me, i thought of creating a minesweeper solver... With the math part it would be okey, but the programming and windows api related stuff i think i would get lost...
If anything it's a great excersise in converting ideas into code. If you're familiar with sudoku's you'll have some strategies which you use, the challenge now is to express those strategies into code. I've already been able to solve a very simple sudoku, but I'm struggling with the harder ones. Ah well it'll work eventually :p

And about the book, it's really good if you've got some experience with programming. It does explain the basics, but goes into slightly more advanced things fairly quickly I found. In that way it's pretty much perfect for me. :)
It may be banal, but the hard part for me are those bloody pointers... Classes are okey, and they are easier to follow but pointers are killing me... :(
If you're struggling with pointers, you're probably thinking about them wrongly. Dump any analogies you're trying to use as a crutch and get to what they are.

They're a data type, like any other. They're usually the same size as an int. They hold a number. That number might be zero, in which case it is a "null pointer" - this just means you're not using it for anything and it's easy to recognise this.

You could put a number in them. Any number you like. It will store that number; let's call that number X. So far, they're just like an int. You don't have any trouble with an int, do you?


The only special thing you can do with a pointer is dereference it; this is an operation that simply means "give me what's at the memory location X". The compiler knows what kind of object that will be based on how you declared the pointer.

That's all there is to it. A pointer is an object that holds a number X, and you can "dereference" the pointer which just gives you the object at memory location X.
But i can use it as a some sort of "place holder". So what allocates memory for a variable that i will use in the future or in another class. That's done with pointers right?

So for my command propt game i make the level with a pointer that hold ascii characters like char** because of the two dimension.
What's so hard about pointers?
They're simply variables which store memory addresses. Their value is a memory address. Then you use * (poor choice of symbol IMO) to jump to that memory address and modify its contents.

http://www.cplusplus.com/doc/tutorial/pointers/

EDIT:
What allocates memory? You can use new and new[]:
1
2
int *one = new int[32]; // new[] -- a C style array of integers
char *c = new char; // one value 

A C-style array is when you store values interpreted as the same type, in contiguous succession, in memory. Character arrays are not different; but sometimes functions that get an address char * do not stop at the first element, but iterate them all (i.e. for printing them) until they reach NULL (which is put there automatically and is usually the value 0).
Last edited on
I made up my mind, would you say it is bad to begin with the basics of directX/openGL programing...? I know the B-A-S-I-Cs of c++ and it may be a good idea to concentrate on what i would like to learn and get the motivation... Or would it be bad at this time?
Which would you prefer dX or oGL?

EDIT: Don't think i would like to start with a complex 3d engine or stuff. For first project something basic for example a simple blank window haha. I just want to get into it.

What is detours by the way?

EDIT #2: For instance i would love to recreate pong...
Last edited on
i was able to handle the error that was posted here. The question up is still a mistery? Please someone?
C++ is a powerful and flexible language but it takes times to grasp. After 2 years of self teaching myself i would find myself at an intermediate level.

As for game programming, start of simple learn c++ then take your time and learn opengl(which is 10x better then direct x) .

A simple answer to your question: A long time, maybe 3-6 years depending how much time you put into it, but many c++ programmers have told me that the c++ learning curve never ends everyday is a new experience and you will never truly "know" the entire language.
I know the B-A-S-I-Cs of c++ and it may be a good idea to concentrate on what i would like to learn and get the motivation... Or would it be bad at this time?

At this point, I would not recommend a DirectX/OpenGL project as a first C++ project. I would recommend knowing the basics + memory management, some STL, file I/O, and inheritance/polymorphism at the least before even thinking about playing with a low-level graphics API (and getting anything reasonable out of it).

Maybe a good first (non-trivial) project would be something like a maze solver. The program would read in something like this from a file:

xxxxxxxxxxx
x---------F
xxx-xxxxxxx
xxx--x--xxx
x----x-x--x
x--xxx--x-x
x-x--x-xx-x
x--x-x----x
x----x-xx-S
xx-x------x
x--x-x-xx-x
xxxxxxxxxxx


where 'x' is a wall, '-' is empty space, 'S' is the starting location, and 'F' is the finish. The program should output the route from S to F. The route would be something like "left, down, left, left, left, left, left, up, ... ". To simplify things you can make it so you can only go horizontally and vertically. First, you can have it output any path at all (as long as it goes from S to F). Then, you can make it so the program computes the shortest path.

After that, you could play around with a simple graphics library, such as SFML. You could first get some simple animation working (a bunch of squares and circles moving across the screen, for example). Then, you could try re-creating Pong. Maybe after you're done Pong, you could use the maze solver solution to re-create Pac Man. The maze solver solution could be the ghost AI.

If you have decent implementations of the above, then I would think DirectX/OpenGL would be a reasonable next step.
Last edited on
people, stay away from Sudoku :) it looks easy, but very complicated for a beginner. I gave up after 300 lines of code.
and also,
a Sudoku solver is different than a Sudoku game. for the game, you need to initialize the board. which is pain in the ....
imo...
I'm currently at 560 lines, with a good design overal (at least I like to think so :p). I'm pretty confident I can pull it off. If there's any interest I'd be willing to post the code on these forums once it's done.
I believe someone in this forum has done it via the C/C++ approach. You all can call out his nick :)
Topic archived. No new replies allowed.