in
Welcome to Lionhead Community Sign in to Windows Live ID | Help

C++ Learning

Last post 10-26-2009, 14:25 by sim656. 47 replies.
Page 1 of 2 (48 items)   1 2 Next >
Sort Posts: Previous Next
  •  08-31-2008, 15:58 3044619

    C++ Learning

    Hello

    My name is Andy, and i'm a 13 year old Swedish... Teen.

    A while now, i've been looking away from my usual modding to take a look at C++ which nowadays is a MUST in the game industry apparently. So for the past two days i've been reading through the awful http://en.wikibooks.org/wiki/C%2B%2B_Programming/TOC1 C++ Wiki Book.  I really started thinking it was supposed to be that hard to learn CPP programming. But a friend told me that Wiki Books are usually overly difficult, at this point i jumped around in happiness thinking that there might still be some way for me to learn it.

    So right now i'm looking at http://www.dummies.com/WileyCDA/DummiesTitle/C-For-Dummies-5th-Edition.productCd-0764568523,subcat-PROGRAMMING.html this.  The description there says that the CD will cover everything other than the guidance from the book. However, in my experience, you would need mathematical skills in stuff like algebra, trignomethry etc etc to work with CPP.

    I would persistantly motivate my dad to let me buy that book, but i don't want to spend money on something i wouldn't understand for several years yét. So is it possible for me to actually learn CPP without a super high maths-certificate?

    And my other question...  I've seen different feedback on that book, is it really user-friendly?  Despite being 13 years old i am not an idiot, i can pick up difficult things, but that Wiki Book was just way beyond me, is this book going to be same?'

    Thanks for any answers!






    T's just a Flesh Wound!
  •  08-31-2008, 19:41 3044887 in reply to 3044619

    • Sarcross is not online. Last active: 11-01-2009, 14:25 Sarcross
      A1MB0TT3R
    • Top 500 Contributor
    • Joined on 08-06-2008
    • Under your bed, behind that shoe no the other one.
    • Senior Member
    • old karma : 0

    Re: C++ Learning

    I'm kinda in the same situation you're in, but what I do is use this and this for a tutorial. I picked up some of the basics so far. No I don't think you'll need any major math skills, but I'm not that far myself.
  •  09-01-2008, 9:57 3045716 in reply to 3044887

    Re: C++ Learning

    That looks great Sarcross!  Thank you very much, finally a decent tutorial Big Smile [:D]




    T's just a Flesh Wound!
  •  09-01-2008, 11:29 3045787 in reply to 3045716

    • Sarcross is not online. Last active: 11-01-2009, 14:25 Sarcross
      A1MB0TT3R
    • Top 500 Contributor
    • Joined on 08-06-2008
    • Under your bed, behind that shoe no the other one.
    • Senior Member
    • old karma : 0

    Re: C++ Learning

    I'm glad I was able to help. In the second link it encourages you to add stuff to the coding to see what'll happen. Oh and I use Microsoft Visual C++2008 and 2005 as a compiler, I don't know about others, but when you make a mistake in the coding, when the debugging fails it tells you what It can't do from the line in the programming, and then it can highlight that section so you can fix it.
  •  09-01-2008, 13:07 3045896 in reply to 3045787

    Re: C++ Learning

    You really are a psychic, aren't you?

    I've been having major difficulties with compilers, thanks again!






    T's just a Flesh Wound!
  •  09-01-2008, 14:11 3046021 in reply to 3045896

    • Sarcross is not online. Last active: 11-01-2009, 14:25 Sarcross
      A1MB0TT3R
    • Top 500 Contributor
    • Joined on 08-06-2008
    • Under your bed, behind that shoe no the other one.
    • Senior Member
    • old karma : 0

    Re: C++ Learning

    No, not psycic, psyco! Crazy [:crazy:] =)

    But yeah make sure you register, its free, but I think you have to make an account or something, not completely sure. They have other compilers too and some dev tools, one of them has templates for games, but me being a -3 on a scale of 1-10 of programming, I don't know how to work it lol. Umm, here's a simple area calculator program I just wrote :

    #include <iostream> //Your header file, you need this for the cout and cin functions

    #include <ostream>

    #include <istream>

    #define vol ( length * width * height) // Tells the compiler what "vol" is equal to

    using namespace std;

    int main()

    {

    int length;

    int width;

    int height;

    cout << "Input Length.";

    cin >> length;

    cout <<"Now input width.";

    cin >> width;

    cout <<"Finally, input height.";

    cin >> height;

    cout <<"The volume of the rectangle is: ";

    cout << vol;

    cin.get ();

    return 0;

    }

    You can take out the #include <istream> and <ostream> parts, I was just experimenting, and learned through this that if you're going to use "cout" and "cin" you absolutely NEED the iostream header or you won't get results. Hmmm I'll explain a little bit for you.

    The #define vol tells the compiler that "vol" is a sumpthing (LOL) and that it is equal [()] to length * width * height. the int length ,width, and height are your interger values that will be inputed. The cout displays the words in quotes "", and the cin >>  is what you enter for the corresponding interger value. so if length was 1, width was 2, and height was 3, it would ask for the values, multiply them

  • then display them because of the lines

    cout <<"The volume of the rectangle is: ";

    cout << vol;

    then the cin.get (); waits for you to press enter before the program closes, but for some reason it kept closing after giving me the volume without my input, but I'll figure it out.

    I hope I helped more than I confuzzled =)

  •  09-01-2008, 14:35 3046067 in reply to 3046021

    Re: C++ Learning

    Wow, that's a really neat explanation. I have some past experience with coding, but C++ is confusing me most of the time, but your example helped me alot!

     

    I did get some note about 30 day registration... Now to find out how to... Rolleyes [:rolleyes:]






    T's just a Flesh Wound!
  •  09-01-2008, 14:51 3046098 in reply to 3046067

    • Sarcross is not online. Last active: 11-01-2009, 14:25 Sarcross
      A1MB0TT3R
    • Top 500 Contributor
    • Joined on 08-06-2008
    • Under your bed, behind that shoe no the other one.
    • Senior Member
    • old karma : 0

    Re: C++ Learning

    I'm drawing a blank on the registration process, but I assure you its free. My next task is to make a random number generator, I've tried before, but I couldn't figure out how to make it work. Oh and make sure that all of your symbols correspond to the function they're with. I made a mistake and put cout >> instead of cout <<, messed up the rest of the coding.

    When you write something you like, post it, I wanna see how other people do it.

  •  09-01-2008, 14:51 3046099 in reply to 3046067

    • Sarcross is not online. Last active: 11-01-2009, 14:25 Sarcross
      A1MB0TT3R
    • Top 500 Contributor
    • Joined on 08-06-2008
    • Under your bed, behind that shoe no the other one.
    • Senior Member
    • old karma : 0

    Re: C++ Learning

    I'm drawing a blank on the registration process, but I assure you its free. My next task is to make a random number generator, I've tried before, but I couldn't figure out how to make it work. Oh and make sure that all of your symbols correspond to the function they're with. I made a mistake and put cout >> instead of cout <<, messed up the rest of the coding.

    When you write something you like, post it, I wanna see how other people do it. Only

  •  09-01-2008, 14:51 3046100 in reply to 3046067

    • Sarcross is not online. Last active: 11-01-2009, 14:25 Sarcross
      A1MB0TT3R
    • Top 500 Contributor
    • Joined on 08-06-2008
    • Under your bed, behind that shoe no the other one.
    • Senior Member
    • old karma : 0

    Re: C++ Learning

    I'm drawing a blank on the registration process, but I assure you its free. My next task is to make a random number generator, I've tried before, but I couldn't figure out how to make it work. Oh and make sure that all of your symbols correspond to the function they're with. I made a mistake and put cout >> instead of cout <<, messed up the rest of the coding.

    When you write something you like, post it, I wanna see how other people do it. Only way

  •  09-01-2008, 14:51 3046101 in reply to 3046067

    • Sarcross is not online. Last active: 11-01-2009, 14:25 Sarcross
      A1MB0TT3R
    • Top 500 Contributor
    • Joined on 08-06-2008
    • Under your bed, behind that shoe no the other one.
    • Senior Member
    • old karma : 0

    Re: C++ Learning

    I'm drawing a blank on the registration process, but I assure you its free. My next task is to make a random number generator, I've tried before, but I couldn't figure out how to make it work. Oh and make sure that all of your symbols correspond to the function they're with. I made a mistake and put cout >> instead of cout <<, messed up the rest of the coding.

    When you write something you like, post it, I wanna see how other people do it.

  •  09-01-2008, 15:56 3046255 in reply to 3046101

    Re: C++ Learning

    LOL, way to go on the quadraple post Wink [;)]

    I'll see if i can get this registration thing working, and on a side note: i don't think i will get many programs up very soon! Stick out tongue [:P]






    T's just a Flesh Wound!
  •  09-01-2008, 16:33 3046334 in reply to 3046255

    • Sarcross is not online. Last active: 11-01-2009, 14:25 Sarcross
      A1MB0TT3R
    • Top 500 Contributor
    • Joined on 08-06-2008
    • Under your bed, behind that shoe no the other one.
    • Senior Member
    • old karma : 0

    Re: C++ Learning

    Holy crap I didn't see that lmao. Oh, and start simple, do the basic "Hello World' program, then work your way to intergers and make a simple calculator for area or something. Sooner or later I'm gonna start back up on if and else statements. These help your program "think" by giving it options or something. so Say its like

    {

    ...                //LMAO thats the first of the code, I just don't know what that code is

       if ( The world is round)      

          {

                cout << "GET IN MY BELLY!";

          }

       else

          {

                cout << "You... suck... bigtime...";

          }

       cin.get();

       return 0;

    }

  •  09-03-2008, 15:03 3049257 in reply to 3046334

    Re: C++ Learning

    Okay... So i'm actually understanding most of the basics. However, the part that i'm still lost about, is the Compiling thing.

    I'm writing my code in Microsoft Visual C++, as a new file, i enter the code. And... Now what? There doesn't appear to be any compile button? And the tutorials are really weak at explaining this specific step. How do i actually get to fire up my written programs?






    T's just a Flesh Wound!
  •  09-04-2008, 23:08 3051043 in reply to 3049257

    • Sarcross is not online. Last active: 11-01-2009, 14:25 Sarcross
      A1MB0TT3R
    • Top 500 Contributor
    • Joined on 08-06-2008
    • Under your bed, behind that shoe no the other one.
    • Senior Member
    • old karma : 0

    Re: C++ Learning

    Press F5 to debug, or there should be a drop down menu at the top under Debug I think(not on the right computer). But yeah F5 is the shortcut key and If you did anything wrong it'll tell you, it's just gonna be hard to figure it out sometimes because it uses different codes for different errors. Ones like C4813 or sumptin and it doesn't give a clear explanation on whats wrong.

  •  09-05-2008, 8:53 3051370 in reply to 3051043

    Re: C++ Learning

    I'm a bit confused Confused [*-)]

    I want to compile my code, so that i can see what i've done. For example, to get the Hello World program fired up.

    F5 Is to start Debugging, which i for some reason can't even do, it's greyed out.

     

    So... To summarize: How do i compile my code? Wink [;)]






    T's just a Flesh Wound!
  •  09-05-2008, 9:33 3051411 in reply to 3051370

    • Sarcross is not online. Last active: 11-01-2009, 14:25 Sarcross
      A1MB0TT3R
    • Top 500 Contributor
    • Joined on 08-06-2008
    • Under your bed, behind that shoe no the other one.
    • Senior Member
    • old karma : 0

    Re: C++ Learning

    Hmm, I never encountered this problem, can you post a screen so I can see what you're doing?
  •  09-05-2008, 11:19 3051528 in reply to 3051411

    Re: C++ Learning

    Is debug equal to Compile?

    It seems more like... a simple debugger.

     

    Either way, the F5 (Start Debugging) is simply just greyed out.






    T's just a Flesh Wound!
  •  09-05-2008, 19:53 3052200 in reply to 3051528

    • Sarcross is not online. Last active: 11-01-2009, 14:25 Sarcross
      A1MB0TT3R
    • Top 500 Contributor
    • Joined on 08-06-2008
    • Under your bed, behind that shoe no the other one.
    • Senior Member
    • old karma : 0

    Re: C++ Learning

    Yeah its equal. I still havent figured out why it's greyed out. Can you give me your process i.e. start new project, then new source code, then yadda yadda until you get to where you want to compile.
  •  09-05-2008, 20:49 3052298 in reply to 3052200

    Re: C++ Learning

    The Debugger is not the same as compiling. In a nutshell, compiling translates your code (which is comprehensible to you) into machine code, as in 1's or 0's (which is comprehensible to the computer).

    The debugger is a useful tool for finding why your program is crashing. Among other things, you can insert Breakpoints, which can pause your program in certain places so you can see if it is reaching certain statements. Additionally you can view memory dumps to see where exactly stuff is getting stored, etc.

     

     

    EDIT: There should be an option in your version of visual studio in the toolbar to Compile. After it has worked its magic without throwing any errors, go to [Debug>Start without debugging] to run the code.


    Philosophical Ninja.
  •  09-06-2008, 4:17 3052750 in reply to 3052298

    Re: C++ Learning

    Thanks both of you!

    So i actually have to start a new project, then a new .cpp file for that one. I'm still a bit confused about this, but atleast i can debug now! Big Smile [:D]

     

     

    ___________________

    #include <iostream>

    using namespace std;

    int main ()

    {

    int a;

    cout <<"How old are you?";

    cin >> a;

    if (a<20)

    {

    cout <<"You're " << a <<" years old? Wow, so young!";

    return 0;

    }

    else if (a>19, a<50)

    {

    cout <<"You're " << a <<" years old? Wow, so middle-age!";

    return 0;

    }

    else if (a>49)

    {

    cout <<"You're " << a <<" years old? Wow, so old!";

    return 0;

    }

    }

    _________________________________________

     

    Now, running with debugging doesn't get me very far... I only get to enter my age and then it auto closes for some reason, but i guess that doesn't matter. So i run it without debug, and now it works perfectly, except for the thing about "Waiting for user to press key of choice" (or somethig like that) at the end of the code. And it's also on the same line as the "You're "a" years old? Wow,so old!"  so that it looks kind of bugged, anyway to remove this feature but still having the program running so that the user can see their insult/age returned to them?






    T's just a Flesh Wound!
  •  09-06-2008, 8:07 3052857 in reply to 3052750

    Re: C++ Learning

    well i dont actually use C++ but i assume like in delphi or pascal you could just make you're quote go to the next line so that the press key of choice message doesnt appear on the same line as your message, and i assume that the key of choice will be the exit mechanism as it is not coded into any visual forms yet and you have not made any code to stop the program from running, i hope this makes sense to you.
  •  09-06-2008, 8:10 3052861 in reply to 3052750

    Re: C++ Learning

    well i dont actually use C++ but i assume like in delphi or pascal you could just make you're quote go to the next line so that the press key of choice message doesnt appear on the same line as your message, and i assume that the key of choice will be the exit mechanism as it is not coded into any visual forms yet and you have not made any code to stop the program from running like the halt command in delphi, i hope this makes sense to you.
  •  09-06-2008, 16:01 3053351 in reply to 3052861

    Re: C++ Learning

    If you run the program off the debug.exe file created, then it will autoclose as soon as it hits a return statement in main. As you can see, you do this inside all of your if statements. (Try just having one return 0 statement, but place it after all the if, else-if statements)

    When you are doing a start without debugging, it will pause at the end, waiting for you to close. If you'd rather run off the debug.exe file, which is autoclosing on you, insert one of the following lines of code at the end of your program:

    cin.get();

    or

    system("pause");


    Philosophical Ninja.
  •  09-06-2008, 18:46 3053645 in reply to 3053351

    • Sarcross is not online. Last active: 11-01-2009, 14:25 Sarcross
      A1MB0TT3R
    • Top 500 Contributor
    • Joined on 08-06-2008
    • Under your bed, behind that shoe no the other one.
    • Senior Member
    • old karma : 0

    Re: C++ Learning

    I've done cin.get(); before but it still closes the program. and never saw the system("pause") before.
Page 1 of 2 (48 items)   1 2 Next >
View as RSS news feed in XML