Sign in to follow this  

Starting out on my C++ foot

This topic is 4197 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I'm new to game development and I ordered a book on C++. I have my reasons to start out on C++ (and the book I ordered is great or so says 22 people) But should I really start out with something else first like BASIC?

Share this post


Link to post
Share on other sites
Just my two cents, Java isnt really any better than C++ for begginners, in fact, the whole "main is a static class member" thing, could even confuse them more. But I second the vote for python, python is quite nice, and I think if nothing else, Cyncro, you should give it a look

cheers
-Dan

Share this post


Link to post
Share on other sites
Python is what people generally advise here as your "learning language". I started with C and it was fine. Starting with C++ is really not that much different from starting with C so from personal experience it's a fine place to start.

-me

Share this post


Link to post
Share on other sites
Yeah im going to stick with C++ and learn a second language from there. The book is great. I started out today and I am very happy to announce that I executed a succesful Hello World program!

Share this post


Link to post
Share on other sites
Quote:
Original post by Cyncro
I have my reasons to start out on C++...


If you have your reasons and think they're good, then just go with C++. I did and I am doing alright. Just be patient (which applies to all languages...) and you'll do fine.

Share this post


Link to post
Share on other sites
The language you start out with dosen't matter much. You're not going to start out with the hardest parts of C++(or any langauge) as the first thing, So if you've got a good reasone and a book, stick with C++, BASIC won't be that much easier in the begining anyway.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ademan555
Just my two cents, Java isnt really any better than C++ for begginners, in fact, the whole "main is a static class member" thing, could even confuse them more. But I second the vote for python, python is quite nice, and I think if nothing else, Cyncro, you should give it a look

cheers
-Dan


One would think that not having to muck about with pointers, references, memory allocation and deallocation, and mixed C/C++ is an advantage when starting out programming. :D

But I'm not trying to advocate Java per se (even if I am a convert, heh), just pointing out that there are more options than just C++ and Basic. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by lightbringer
One would think that not having to muck about with pointers, references, memory allocation and deallocation, and mixed C/C++ is an advantage when starting out programming. :D


I understand the comment, but nothing says you have to use pointers, references, and other countless 'confusing' (or so accused) features of a language. And I'm not sure I understand the mixed C/C++ comment, because he said he's using C++, which doesn't imply the use of any C, but maybe that's not what you're saying. Books typically do a good job of explaining good practices and advanced topics, though, or at least more so than an online tutorial.

Out of curiosity, which book are you using?

Share this post


Link to post
Share on other sites
It's called "Beginning C++ for Game Developers" I beleive. I heard it's not for absolute beginners so I'm trying to learn some stuff now. I heard it was a great book. I'm having trouble understanding some of this stuff. Please someone check out this webstie and tell me if it's good because I don't think they are clear enough. http://www.cprogramming.com/

Share this post


Link to post
Share on other sites
Quote:
Original post by bschneid
I understand the comment, but nothing says you have to use pointers, references, and other countless 'confusing' (or so accused) features of a language. And I'm not sure I understand the mixed C/C++ comment, because he said he's using C++, which doesn't imply the use of any C, but maybe that's not what you're saying. Books typically do a good job of explaining good practices and advanced topics, though, or at least more so than an online tutorial.


Those are core features of C++, why would you not use them? :D They are not so much "confusing" as "unforgiving" though, imho.

By mixed I meant that the distinction is too blurry. I don't deal with C++ at all so I may be completely wrong here, but I believe that there is nothing inherent in C++ that prevents you from mixing in legacy C-style code?

And yeah, completely agree - books beat online language primers/tutorials, which more often than not are written by people who have just read a chapter of some book and suddenly feel qualified to pass on their "wisdom".

Anyway, C++ is widespread and powerful and as good a choice as any - it may require more commitment to learn it but that knowledge will most likely be advantageous. As long as the OP is not learning Basic or ASM as his first language, it's all good :D

Share this post


Link to post
Share on other sites
Quote:
Original post by Cyncro
It's called "Beginning C++ for Game Developers" I beleive. I heard it's not for absolute beginners so I'm trying to learn some stuff now. I heard it was a great book. I'm having trouble understanding some of this stuff. Please someone check out this webstie and tell me if it's good because I don't think they are clear enough. http://www.cprogramming.com/


If you want to get your feet wet before your book arrives, you might want to check out this eBook. These are two printed books available as a free download. While I can't comment on these per se, it's better than reading tutorials. Also, I learned Java with Bruce Eckel's other book, Thinking in Java. He has a way with words and understandable explanations and offers interesting insights into OO programming in general.

Share this post


Link to post
Share on other sites
Quote:
Original post by lightbringer
Quote:
Original post by Cyncro
It's called "Beginning C++ for Game Developers" I beleive. I heard it's not for absolute beginners so I'm trying to learn some stuff now. I heard it was a great book. I'm having trouble understanding some of this stuff. Please someone check out this webstie and tell me if it's good because I don't think they are clear enough. http://www.cprogramming.com/


If you want to get your feet wet before your book arrives, you might want to check out this eBook. These are two printed books available as a free download. While I can't comment on these per se, it's better than reading tutorials. Also, I learned Java with Bruce Eckel's other book, Thinking in Java. He has a way with words and understandable explanations and offers interesting insights into OO programming in general.


Ok thanks I'll take a look at them right now.

Share this post


Link to post
Share on other sites
Quote:
Original post by lightbringer
By mixed I meant that the distinction is too blurry. I don't deal with C++ at all so I may be completely wrong here, but I believe that there is nothing inherent in C++ that prevents you from mixing in legacy C-style code?


You are correct good sir. The most annoying thing is when books use c-style 'strings' (ie char string[50]) instead of C++ string objects. I find a lot of this online, and its quite annoying...(Cyncro, make note NOT to use anything like the first example in regards to strings of text :) )

EDIT: I looked at the first tutorial for C++ (Intro to C++, I think) and the fact that I saw the words preprocesser directive tells me that it moves way to fast and/or its got its priorities all wrong. There isn't a reason to try to explain what #include does before showing you how to make the console say hello world. All you need to know for now is that #include <iostream> makes it possible to display text and receive user input. The specifics of how should come later, especially if you are knew to programming as a whole. I wouldn't worry if you don't understand those tutorials. Plus, I personally don't like to use the "cin.get()" function, but that's just me. I'd stick with the book.

Share this post


Link to post
Share on other sites
Some of this stuff is confusing, the tutorials barly explain stuff in terms I understand. I'm very dedicated to learn but I can't find any good tutorials. I checked out the E-book and it's a bit less confusing but not as good as I would have liked. I keep getting an error message here as well when trying to do these strings and trying to put eh cin.get. Take a look.

#include <string>
using namespace std;

int main() {
string imBlank;
string heyMom("Where are my socks?");
string standardReply = "Beamed into deep "
"space on wide angle dispersion?";
string useThisOneAgain(standardReply);
cin.get ();
} ///:~

Share this post


Link to post
Share on other sites
Just a note on Bruce Eckel -- I like his books and find them relatively good, but a word of warning:

They assume a prior knowledge of C. Well, the Thinking in C++ one does anyway -- so, while chapter 3 is about C stuff (char arrays, pointers, structs, blah) -- so, the C in C++, it doesn't give any great depth to these subjects before it goes onto more C++ stuff (containers, classes, iterators & templates, etc).

So, that said -- Bruce is fine if you don't mind a steep learning curve and lack of examples of different usage of language constructs (always one or two examples, but never proper ones...), though his prose is quite easy to understand.

~Shiny.

Share this post


Link to post
Share on other sites
The bug with cin.get is that you haven't included <iostream> which is where cin comes from :) -- haven't read code properly though, so it might come from somewhere else. Try including that header first though.


~Shiny.

Share this post


Link to post
Share on other sites
Quote:
Original post by Shiny
The bug with cin.get is that you haven't included <iostream> which is where cin comes from :) -- haven't read code properly though, so it might come from somewhere else. Try including that header first though.


~Shiny.

thanks.

Share this post


Link to post
Share on other sites
No it still won't work. I know I'm doing something wrong. Here's the new code.
#include <string><iostream>
using namespace std;

int main() {
string imBlank;
string heyMom("Where are my socks?");
string standardReply = "Beamed into deep "
"space on wide angle dispersion?";
string useThisOneAgain(standardReply);
cin.get ();
} ///:~

Share this post


Link to post
Share on other sites
Quote:
Original post by Cyncro
No it still won't work. I know I'm doing something wrong. Here's the new code.
#include <string><iostream>
using namespace std;

int main() {
string imBlank;
string heyMom("Where are my socks?");
string standardReply = "Beamed into deep "
"space on wide angle dispersion?";
string useThisOneAgain(standardReply);
cin.get ();
} ///:~


First thing's first. Whenever you paste code in gamedev, be sure to do it between [_source_] [_/source_] tags (without the underscores)

Second of all. it should be


#include <string>
#include <iostream>



I've never seen them on the same line, it may be valid, but i've never seen it, so i'm going to assume its invalid.

the standard reply thing, I didn't think that you could have two strings like that either. on different lines. instead, put them between the same quotes with a \n like so

string standardReply = "Beamed into deep\n space on wide angle dispersion?";


assuming you wanted a new line there.

hope that helps
-Dan

Share this post


Link to post
Share on other sites
The standardReply string spaced over two lines works fine on g++ 4.x -- no idea what would happen on VC++, and I assume MinGW would be the same...

never seen a string declared that way, but it seems it works -- oh, and it outputs as a single line (no newline inbetween).


~Shiny, on a mac.

Share this post


Link to post
Share on other sites
Interesting, I never knew that. I wonder if thats standards compliant or not, it seems strange since the c++ language really doesnt do a whole lot of catering to character arrays AS STRINGS, if you know what i mean. Regardless, if it works it works, but when you post your questions Cyncro, be sure to post the associated errors as well (copied from your compiler)

cheers
-Dan

Share this post


Link to post
Share on other sites
Thanks but I banished the e book and found a pretty great site that explains everything. but im having a problem keeping my file opened when i run it. even with the cin.get it wont look. please take a look.
// Operating with Variables
#include <iostream>
using namespace std;

int main ()
{
//declaring variables
int a, b;
int result;

//process
a = 5;
b = 2;
a = a + 1;
result = a - b;

//print out the result
cout << result;

//terminate the program
return 0;
cin.get ();
}

Share this post


Link to post
Share on other sites

This topic is 4197 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this