Help Wanted

Learning C++ – skynes

Skynes
Member

Posts: 202
From: Belfast, N Ireland
Registered: 01-18-2004
Games industry requires C++.

Skynesey learnt Java (stupud University)

So how should I go about learning C++? what should I be striving to accomplish to begin with?

'cout "hello worlds"'? Or something else?

Any good resources or books?

CPUFreak91

Member

Posts: 2337
From:
Registered: 02-01-2005
quote:
Originally posted by skynes:
'cout "hello worlds"'? Or something else?

Any good resources or books?


Well for one, your syntax is wrong .

cout >> "hello worlds";

www.cprogramming.com -- nice resource.
http://cppreference.com/ -- You might find it useful, I have.
http://kgptech.blogspot.com/2005/07/cc_112128559089023869.html -- Lots of links there

------------------
All Your Base Are Belong To Us!!! chown -r us ./base
"After three days without programming, life becomes meaningless.'' -- Tao of Programming Book 2

"Oh, bother," said the Borg. "We've assimilated Pooh."

Open source, open mind.

My Programming and Hacker/Geek related Blog

[This message has been edited by CPUFreak91 (edited September 27, 2007).]

steveth45

Member

Posts: 536
From: Eugene, OR, USA
Registered: 08-10-2005
quote:
Originally posted by CPUFreak91:
Well for one, your syntax is wrong


So is yours.

cout << "Hello, worlds.";

I'd say, get a C++ textbook. As long as it's fairly recent and not a "C++ in 24 hours" or "idiot's guide" kind of book, it should be pretty good. Start by reading through the Wikipedia page on C++ which covers the history and the major language features so you know what you are getting into.

------------------
+---------+
|steveth45|
+---------+

CPUFreak91

Member

Posts: 2337
From:
Registered: 02-01-2005
quote:
Originally posted by steveth45:
So is yours.

Oops.

------------------
All Your Base Are Belong To Us!!! chown -r us ./base
"After three days without programming, life becomes meaningless.'' -- Tao of Programming Book 2

"Oh, bother," said the Borg. "We've assimilated Pooh."

Open source, open mind.

My Programming and Hacker/Geek related Blog

SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
So is...oh, nevermind.

Skynes, don't be too hard on your education on Java. Learning any language is good and will be that much easier to learn a new one. A lot of syntax is similar across languages (for loops, if statements, etc.) and learning Java should mean you have an understanding of OO concepts. These factors alone should really help in learning C++.

One of your big issues will be learning about memory management. Where Java cleaned up all of your memory for you using garbage collection, C++ requires the developer to delete memory when it is no longer needed.

Skynes
Member

Posts: 202
From: Belfast, N Ireland
Registered: 01-18-2004
I knew my syntax was wrong :P

I'll look at those sites thanks.

As for books what of the C++ for Games ones?

Or is general C++ better to focus on?

steveth45

Member

Posts: 536
From: Eugene, OR, USA
Registered: 08-10-2005
quote:
Originally posted by skynes:
As for books what of the C++ for Games ones?

Or is general C++ better to focus on?


My experience with "general" game programming books is that they tend to focus on particular API's, instead of game programming in general. I'd stick with the straight C++ books. You can learn all you need to about particular API's from the 'net.

------------------
+---------+
|steveth45|
+---------+

leet hacker

Member

Posts: 118
From: Hobbiton, Shire, Middle-Earth
Registered: 07-30-2007
even though i don't know c++ (or any programming languages, for that matter ), there is a book on wikibooks about c++ programming that i am planning on reading sometime. hope this is helpful!

------------------
This post Copyright 2007 leet hacker. All rights reserved. No part of this post may be reproduced or transmitted in any form or by any means, electronic or mechanical, including quoting, without the express written consent of the author.
ISPN: 1-234567-890-1
Archive of Posts Catalog Card Number: 1234567890
10 9 8 7 6 5 4 3 2 1
You have express written consent to quote this post.

D-SIPL

Moderator

Posts: 1345
From: Maesteg, Wales
Registered: 07-21-2001
quote:
Originally posted by steveth45:
My experience with "general" game programming books is that they tend to focus on particular API's, instead of game programming in general. I'd stick with the straight C++ books. You can learn all you need to about particular API's from the 'net.


Good advice.

I would forget about game programming in C++ for now. Get the basics nailed first learn about functions, variable, data types, try looking into some statements like switch/case and then put together a little text based game to practice what you have learnt.

Then look into OOP programming, check out classes etc and re-write your text based game applying what you have learnt from that. Once you have completed that, look into Win32 programming, initialization, message handling etc. I would say after that you will be ready to start some graphical game programming with C++. Maybe start with a library like SDL or Allegro and then move onto DirectX.

During my Game Develoment Degree this is the route we have taken and it has worked really well.

------------------
"One World. One Web. One Program." -Microsoft promotional advertisement
"Ein Volk, ein Reich, ein Fuhrer!" -Adolf Hitler

Skynes
Member

Posts: 202
From: Belfast, N Ireland
Registered: 01-18-2004
OOP I know back to front. I do it naturally.

To begin with I really need the structure of the language. things should be much simpler after that.


*thinks*


It's occured to me I haven't said I've done an awful lot of C#. Both during my degree and Dare to be Digital.

Calin

Member

Posts: 358
From: Moldova
Registered: 12-04-2006
Well if 'games industry' is what you're aiming at then you need to learn C++ . However if getting into games industry is not your #1 priority and you still want to make (/try to make) games then you can use C# for that. There's a number of engines (including free ones) that will let you do the programming of your games in C# (without the headache of writing your own wrapper )

------------------
Every algorithm has a creator

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
So far I've like Thinking in C++. Its free, and pretty good. A bit difficult to understand for somethough. Google is your best friend.

A couple other good stuff:
http://www.cprogramming.com/tutorial.html#c++tutorial Pretty good tut. I learned my first programs from this.

http://www.programmingtutorials.com/cplusplus.aspx From what it looks like this is pretty good, can't tell you much first hand though.

I've also been enjoying: Accelerated C++. by Andrew Koenig, and Barbara E. Moo. 12th printing October 2005.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto
I reserve the full right to change my views/theories at any time.

CPUFreak91

Member

Posts: 2337
From:
Registered: 02-01-2005
quote:
Originally posted by Calin:
Well if 'games industry' is what you're aiming at then you need to learn C++ . However if getting into games industry is not your #1 priority and you still want to make (/try to make) games then you can use C# for that.

Some say C# is Microsoft's version of Java. You might be able to pick that up pretty quickly .

------------------
All Your Base Are Belong To Us!!! chown -r us ./base
"After three days without programming, life becomes meaningless.'' -- Tao of Programming Book 2

"Oh, bother," said the Borg. "We've assimilated Pooh."

Open source, open mind.

My Programming and Hacker/Geek related Blog

Skynes
Member

Posts: 202
From: Belfast, N Ireland
Registered: 01-18-2004
Games Industry is what I'm aiming for.

C# I know pretty well.

samw3

Member

Posts: 542
From: Toccoa, GA, USA
Registered: 08-15-2006
I'd say if you just want to learn C++ syntax and best practices get a general book. Programming games, tho, is a distinct programming paradigm, similar to real-time systems or simulations. You probably won't find the patterns, algorithms, and best practices for game programming in a general C++ book.

So, if you already got the game algorithms under your belt, just get a c++ book, otherwise you might want to pick up a good game algorithms book.

Does anyone know of a book that details common game algorithms? One that could be helpful to anyone wanting to write games in any language?

God Bless!

------------------
Sam Washburn

Check out my CCN SpeedGame 2 Blog

Skynes
Member

Posts: 202
From: Belfast, N Ireland
Registered: 01-18-2004
Here's what I've noticed so far.

cout << is odd. I'll be ok with it, but it's different to what I'm used.

cin.ignore will be a new addition. I've never given thought before to enter being a character and having to manually ignore it.

If statements are the same as I know
Switch statements are the same as I know
Pointers I knew of in theory, nice to be able to use them.

Strings are weird. I'm so used to a variable string that having to revert to an array of characters is very strange and will take getting used to.

Struct and methods I'm mostly fine with. Except this declaring methods like you do variables. That's odd.


Thing is, as long as I know WHY I'm doing something, I'm ok with doing it. I didn't get what

quote:
#include <iostream>

using namespace std;


...was for. Research showed it to be including the standard library and the in out stream (the iostream I figured out on my own). So I'm content to include them

samw3

Member

Posts: 542
From: Toccoa, GA, USA
Registered: 08-15-2006
quote:

#include <iostream>
using namespace std;

Think of these both as a single "import" statement in java. Java knows where to get the file to import based upon a standardized directory structure. C++ doesn't, so the #include statement includes a file (most of the time a header file) to be compiled with the current file.

The "using" statement imports a namespace into the local context of the current file, kind of like "import" in java. Your program can function without it but you would have to type std::cout instead of just cout. (:: is the namespace resolver in c++)

God Bless!

------------------
Sam Washburn

Check out my CCN SpeedGame 2 Blog

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
I'll give you guys an example to further explain (don't peg me about my syntax please guys, I've not done C++ for a while, and I never was that good.)
without using:

#include<iostream>

int main()
{
int number;
std::cin >> number;
std::cout << "Hello, this is the number you said: ";
std::cout << number;
std::cout << "." << endl;
// I know it can be done only on one line, I'm just emphasizing a point
};


lotsa extra typing, this is good if you're using multiple namespaces I believe.

With using:


#include<iostream>
using namespace std;

int main()
{
int number;
cin >> number;
cout << "Hello, this is the number you said: " << number << "." << endl;
};

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto
I reserve the full right to change my views/theories at any time.

[This message has been edited by Mene-Mene (edited October 02, 2007).]

[This message has been edited by Mene-Mene (edited October 02, 2007).]

[This message has been edited by Mene-Mene (edited October 02, 2007).]

Skynes
Member

Posts: 202
From: Belfast, N Ireland
Registered: 01-18-2004
import is a good comparison. It's what I thought of it when I seen it. But didn't know WHAT I was importing did I did a little reading.
supercoder

Member

Posts: 37
From:
Registered: 08-20-2007
http://www.cppgameprogramming.com
hes simple code and demo code like toetactoe and pong
baby steps u into allegro too.

------------------
>>>--supercoder--<<<

Realm Master

Member

Posts: 1971
From: USA
Registered: 05-15-2005
okay, i'm late in getting to this topic
so here's my quick advice:
If you know java, your pratcially set. the languages are very similar (which could also pose as a problem... but not too much of one)

You just have to get used to graphics librarys and stuff.
(can anyone say "not fun!"?)

there, I done.
others have probably already said that, but if not, then I hope that at least encouraged you a little bit.
There are also some great sites around with C++ on 'em
That one supercoder put up is a good one (If its the site I'm thinking off... lost trak of it long time ago)

------------------
yeah, im a little crazy
Check out my crazy sig that I made:


Skynes
Member

Posts: 202
From: Belfast, N Ireland
Registered: 01-18-2004
http://www.cppgameprogramming.com/cgi/nav.cgi?page=index

seems like a good site. But a few have said, he wants you to use the specific libraries and program he uses... >.< and for the life of me I can't figure out how on earth to get them to work.

lghtngclp

Junior Member

Posts: 3
From: Here
Registered: 09-10-2007
Have you tried

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

------------------
D[a]n

steveth45

Member

Posts: 536
From: Eugene, OR, USA
Registered: 08-10-2005
Since you know the fundamentals of OOP, you're in a good place for learning C++. There are just a few things you'll need to learn, really, like memory management fundamentals, the difference between pointers and references, header files, class construction, and some standard library API for good measure (all the std::cout business).

I program all day in C++, and I rarely touch the standard library, it's really mostly useful as a tool for learning C++, and writing simple, console applications. The std::cout << "Hello World." example actually encompasses a number of difficult or obscure aspects of C++, as it relies on namespaces (the std namespace and :: symbol), static instances (cout), operator overloading (the << operator, which actually is a standard C++ operator for bit-shifting, re-purposed by the arcane standard library for streaming operations), and string literals (anything in quotes). Namespaces work like they do in Java, but use the double colon instead of the period. Operator overloading in C++ allows you to reuse common operators (+, =, ==, <<, >>, etc) as though they were calling methods (functions) of the associated objects. The flexibility of C++ allows for such alien looking constructions, but the standard library could have just as easily made it a normal function call, (std::cout.print("Hello, World.")) C++ was made to be powerful, not easy.

------------------
+---------+
|steveth45|
+---------+