Learning C++

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
ajtgarber
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 97
Joined: Wed Jun 10, 2009 8:56 am

Learning C++

Post by ajtgarber »

A while ago I finished reading a book about learning C++ "Learning C++ through game programming", and I very quickly realized I knew C++ syntactically but I really couldn't do anything with it. I could/can only read and write text to the console. I've also kinda had this issue learning other languages (Objective-C), the books I've read only just seem to teach you syntax and not much else. 1) anyone else had this problem? 2) How should I go about learning the rest? 3) Am I just being stupid?

Code: Select all

HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE
User avatar
dejai
Chaos Rift Junior
Chaos Rift Junior
Posts: 207
Joined: Fri Apr 11, 2008 8:44 pm

Re: Learning C++

Post by dejai »

The C++ language does not come bundled with graphics / graphical user interface libraries by default (unlike say java). The idea is to use third party libraries to create such programs. For example if you wanted to create a 2D video game you could install the SDL library and read through that libraries tutorials and learn how to use their third party graphics library. That would provide the graphical component to the game but you would still be required to write all the logic for the game in c++ such collision, artificial intellegence etc. Also from a historical standpoint graphics changes really quickly and would be very hard for the C++ committee to standardize across all systems so they don't even try and leave it up to someone else which gives programmers more freedom to choose or to create their own libraries. If you want to go even lower you could use C++ and assembly to directly access your video card and then write to the screen that way but we generally like to abstract that away because it is like re-inventing the wheel (it also wouldn't be portable across other systems with different video cards). So we rely on large code bases written by opengl for example that handle all that for us and let us develop the applications we want :)
User avatar
MrDeathNote
ES Beta Backer
ES Beta Backer
Posts: 594
Joined: Sun Oct 11, 2009 9:57 am
Current Project: cocos2d-x project
Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
Programming Language of Choice: C/++
Location: Belfast, Ireland
Contact:

Re: Learning C++

Post by MrDeathNote »

ajtgarber wrote:A while ago I finished reading a book about learning C++ "Learning C++ through game programming", and I very quickly realized I knew C++ syntactically but I really couldn't do anything with it. I could/can only read and write text to the console. I've also kinda had this issue learning other languages (Objective-C), the books I've read only just seem to teach you syntax and not much else. 1) anyone else had this problem? 2) How should I go about learning the rest? 3) Am I just being stupid?

Code: Select all

HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE
Reading books only gets you so far man. When it comes down to it, programming is a "Learn by doing" activity. I had this problem when i first started programming. Also do you mean that writing to the console is the only thing you know how to do, or did you expect to be making windows and stuff. Because as dejai already said you need 3rd party libs for that.
http://www.youtube.com/user/MrDeathNote1988

Image
Image

"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
ajtgarber
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 97
Joined: Wed Jun 10, 2009 8:56 am

Re: Learning C++

Post by ajtgarber »

Thanks for the replies, yeah thats pretty much all I can do at the current moment, the book I got didn't go over files or anything else, just syntax and a bit of the STL
User avatar
MrDeathNote
ES Beta Backer
ES Beta Backer
Posts: 594
Joined: Sun Oct 11, 2009 9:57 am
Current Project: cocos2d-x project
Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
Programming Language of Choice: C/++
Location: Belfast, Ireland
Contact:

Re: Learning C++

Post by MrDeathNote »

ajtgarber wrote:Thanks for the replies, yeah thats pretty much all I can do at the current moment, the book I got didn't go over files or anything else, just syntax and a bit of the STL
I had the same book and i know it is truely shit. If I was you i'd get a different book.
http://www.youtube.com/user/MrDeathNote1988

Image
Image

"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
User avatar
mv2112
Chaos Rift Junior
Chaos Rift Junior
Posts: 240
Joined: Sat Feb 20, 2010 4:15 am
Current Project: Java Tower Defence Game
Favorite Gaming Platforms: N64/Xbox 360/PC/GameCube
Programming Language of Choice: C/++, Java
Location: /usr/home/mv2112
Contact:

Re: Learning C++

Post by mv2112 »

MrDeathNote wrote:
ajtgarber wrote:Thanks for the replies, yeah thats pretty much all I can do at the current moment, the book I got didn't go over files or anything else, just syntax and a bit of the STL
I had the same book and i know it is truely shit. If I was you i'd get a different book.
I have that book also, i would recommend Sam's Teach Yourself C++ in 24 hours, or Sam's Teach Yourself C++ in 21 Days
wearymemory
Chaos Rift Junior
Chaos Rift Junior
Posts: 209
Joined: Thu Feb 12, 2009 8:46 pm

Re: Learning C++

Post by wearymemory »

mv2112 wrote:
MrDeathNote wrote:
ajtgarber wrote:Thanks for the replies, yeah thats pretty much all I can do at the current moment, the book I got didn't go over files or anything else, just syntax and a bit of the STL
I had the same book and i know it is truely shit. If I was you i'd get a different book.
I have that book also, i would recommend Sam's Teach Yourself C++ in 24 hours, or Sam's Teach Yourself C++ in 21 Days
I wouldn't recommend it. In general, those books are terrible. Any self-respecting programmer knows that you cannot learn a programming language in 24 hours or 21 days, and books like those might even be contributing to the OP's problem, as well as many other's. Here's an excellent read on why: Teach Yourself Programming in Ten Years.

Another reason why you might feel like you have only learned the syntax of C++ is because the book you read was over game programming. That may work for languages like GML or Blitz because they were designed specifically for game development, but it will not work for a general-purpose language like C++. If you're going to learn a new language, then you need to learn it without any contingencies. Focus on learning the language for what it is: Multi-paradigm and general-purpose. If you do this, you'll find that you have a better understanding of the language, and the concepts from which it is derived. Above all, don't start out by using separate architectures designed for specific purposes (e.g. Allegro, SDL, OpenGL, etc.) until you are comfortable with your language.

Using programming patterns and designs that speed up rudimentary and complex development processes will also transfer to other languages, and can even be incorporated into your game programming, so I would suggest finding a few good resources on that as well. You won't find everything you need to know in any one book, you'll likely end up with quite a few different resources.

Now, with that said: You will only be able to truly teach yourself programming with time, coupled by experience, and the knowledge of design.

After you have a firm grasp on the language, why not check out Effective C++: 50 Specific Ways to Improve Your Programs and Design (2nd Edition) by Scott Meyers. Joshua Bloch, respected author and Java programmer who was inspired by Scott Meyer's literature to write Effective Java (Second Edition), recommended this book.
User avatar
mv2112
Chaos Rift Junior
Chaos Rift Junior
Posts: 240
Joined: Sat Feb 20, 2010 4:15 am
Current Project: Java Tower Defence Game
Favorite Gaming Platforms: N64/Xbox 360/PC/GameCube
Programming Language of Choice: C/++, Java
Location: /usr/home/mv2112
Contact:

Re: Learning C++

Post by mv2112 »

wearymemory wrote:<Quoting wearymemory's post>
The books are more of a reference that you indirectly learn from, of course you cant learn C++ in 24 hours or 21 days, but you can look at the examples in the books and learn by actually programming.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: Learning C++

Post by XianForce »

wearymemory wrote: I wouldn't recommend it. In general, those books are terrible.
That's one opinion... Honestly though, the information in the books is great. Just know that no matter what book you buy, you essentially won't 'learn' from it. You have to practice, and learning will come from experience. If your like me, and like to have a physical reference handy, Sams Teach Yourself C++ in 21 Days is great. Just don't expect to have everything mastered in 21 days.
wearymemory
Chaos Rift Junior
Chaos Rift Junior
Posts: 209
Joined: Thu Feb 12, 2009 8:46 pm

Re: Learning C++

Post by wearymemory »

XianForce wrote:Honestly though, the information in the books is great.
Perhaps, but I tend to stay away from such books as they can give the wrong impression, and are sometimes not as in-depth. Also, I was a bit brash when I called them "terrible," but I don't want the OP leaving the thread thinking that they could buy the book and be done with it because it happens.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: Learning C++

Post by XianForce »

Yeah definitely ^^.

So bottomline -> Books are mostly going to used as a 'guiding source' and later as a reference. You will not actually 'learn' from them, no matter how much you think you do. The learning is going to come straight from the programming.
ajtgarber
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 97
Joined: Wed Jun 10, 2009 8:56 am

Re: Learning C++

Post by ajtgarber »

Thanks for all the replies everyone :)

I think I'll try the "Learn C++ in 30 days" (or whatever it was) and take it from there. Thanks for the help :)
User avatar
WSPSNIPER
Chaos Rift Regular
Chaos Rift Regular
Posts: 145
Joined: Sun Jan 03, 2010 6:19 pm
Current Project: top down shooter
Favorite Gaming Platforms: ps3
Programming Language of Choice: c++

Re: Learning C++

Post by WSPSNIPER »

for me i keep learning more by just programming. i look back and understand things totally differently then i thought they were. like cout is and ostream variable and the << is an operator. i also understand object orientation a ton more like you can inherit from the sf::Render window class to make you own window instead of including a window in your engine class and if you have a pointer to a parent class it can point to any child class of that type. basically you just learn because a situation calls you to go outside the box and then once you get it to work you understand it...

drop the tutorials and try to do things yourself. if you run into trouble ask on a forum :) good luck
Post Reply