|
|
C++ Learning
Last post 01-11-2010, 3:22 by renzki. 49 replies.
-
08-31-2008, 15:58 |
-
YourAngel
-
-
-
Joined on 08-24-2008
-
-
Junior Member
-
-
-
old karma : 0
-
|
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 |
-
Sarcross
A1MB0TT3R
-
-
-
Joined on 08-06-2008
-
Under your bed, behind that shoe no the other one.
-
Senior Member
-
-
-
old karma : 0
-
|
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 |
-
09-01-2008, 11:29 |
-
-
09-01-2008, 14:11 |
-
Sarcross
A1MB0TT3R
-
-
-
Joined on 08-06-2008
-
Under your bed, behind that shoe no the other one.
-
Senior Member
-
-
-
old karma : 0
-
|
No, not psycic, psyco! =)
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 |
-
YourAngel
-
-
-
Joined on 08-24-2008
-
-
Junior Member
-
-
-
old karma : 0
-
|
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:]](/emoticons/ponder.gif)
 T's just a Flesh Wound!
|
|
-
-
-
-
-
09-01-2008, 15:56 |
-
09-01-2008, 16:33 |
-
Sarcross
A1MB0TT3R
-
-
-
Joined on 08-06-2008
-
Under your bed, behind that shoe no the other one.
-
Senior Member
-
-
-
old karma : 0
-
|
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-04-2008, 23:08 |
-
09-05-2008, 8:53 |
-
YourAngel
-
-
-
Joined on 08-24-2008
-
-
Junior Member
-
-
-
old karma : 0
-
|
I'm a bit confused ![Confused [*-)]](/emoticons/emotion-42.gif)
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 [;)]](/emoticons/emotion-5.gif)
 T's just a Flesh Wound!
|
|
-
09-05-2008, 9:33 |
-
09-05-2008, 11:19 |
-
YourAngel
-
-
-
Joined on 08-24-2008
-
-
Junior Member
-
-
-
old karma : 0
-
|
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 |
-
09-05-2008, 20:49 |
-
Saucemasterpimp
The True Ninja Member
-
-
-
-
Shadows
-
Senior Member
-
-
-
old karma : 110
-
|
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 |
-
YourAngel
-
-
-
Joined on 08-24-2008
-
-
Junior Member
-
-
-
old karma : 0
-
|
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]](/emoticons/emotion-2.gif)
___________________
#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 |
-
09-06-2008, 8:10 |
-
09-06-2008, 16:01 |
-
Saucemasterpimp
The True Ninja Member
-
-
-
-
Shadows
-
Senior Member
-
-
-
old karma : 110
-
|
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 |
Page 1 of 2 (50 items)
1
|
|