• Advertisement
Sign in to follow this  

Is this normal?

This topic is 1977 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

Hi so I am learning C++ and I am understanding what I am learning, in terms I know what they do, but I don't know how to apply them in a setting.

For example, I understand arrays and stuff, but I guess I don't understand how I would use it in a program? I am more just curious if this is normal to understand what I am learning does, I just don't know how to use it yet.

Hopefully this makes since, if not i'll try to clarify it a bit more. Thank's in advance!

Share this post


Link to post
Share on other sites
Advertisement
There is no good answer to your general question. All the features of the language have been added because there was a need for them.

I can give you examples of situations where arrays are useful:
* To represent a chess board, you can use an array of 64 small integers indicating what's in each square.
* A map in a RTS game is usually a grid of squares, which is represented as an array.
* A polynomial in one variable is an array of coefficients.

In C++ you very often will use std::vector instead of arrays, because they are more flexible (you can change their size dynamically).

Share this post


Link to post
Share on other sites
Well my question in general is, is it normal for me not to understand how to like make a program with it even though I know how to make one, and understand what it is, just not how to use it.

Share this post


Link to post
Share on other sites
I would like to tell you that all this stuff will come to you in time. There will be a point where it will sink in and you will get it. But you haven't told us how you are learning C++? There are many ways to learn C++, not all of them are equal. Hopefully your learning source assumes you don't know how to program at all? Books that teach specific languages sometimes target people who are already familiar with programming in general, and aren't very good for complete beginners.

Keep reading and practicing from lots of sources, and it will come in time!


As for arrays, they are a way to store data.

Most of programming involves only 2 things. Allocating memory for data, and operating on that data.

int a; will allocate space for 1 integer(whole number). You can assign a value to a and operate on it.
int a[10]; will allocate space for 10 integers [0-9].

A deck of cards is an array of 52 Card objects;


struct Card
{
int suit;
int value;
}

const int DeckSize = 52;
Card Deck[DeckSize];

You can use a loop, such as this, to iterate over the array
for (int i = 0; i < DeckSize; ++i)
{
Deck.Suit = whatever;
Deck.Value = whatever;
}

Share this post


Link to post
Share on other sites
Many beginners ask this question, but you have to understand that a processor calculates basic instructions and branching logic. A GPU does the same thing but with floats and less branching and more parallelization of instructions. You have to understand that a programming language gives you maximum control over these basic instructions because it isn't software, it is a language, and you are controlling the instructions, albeit in a portable way (like in C/C++). For example, you may see a wall move, but the computer sees that as a model, made up of textures, texture coordinates (floats), texture bitmaps (array of values), and geometric world space coordinates (four floats for homogeneous coordinates). Also, if you are doing linear transforms, you will use matrices and/or quaternions for 3D games, and that is all using arrays, structs, and floats. My best advice is to pay attention and learn, as programming is useful in almost any field.

Share this post


Link to post
Share on other sites

This is entirely normal, and something you will experience again and again throughout your programming career as you discover new concepts over time.

Especially when you are starting out and inexperienced, it can be very difficult to understand the "why" of certain things, or the bigger-picture concepts of how to use those things. Give it time and keep practicing, and you'll start seeing areas where things "itch" - you can't quite say why, but you know there has to be a better way to do things. Pay attention to those itches - they are usually a sign that you are ready to learn a new concept.


Ok thank you. I assumed it was normal, but I just wanted to make sure. Thanks for the posts guys makes me feel a bit better as I was kinda going "crap I don't know how I would use this yet xD".

Anyway I am learning from C++ sams teach yourself one hour a day and these youtube videos: http://thenewboston.org/list.php?cat=16

I really like the way he explains everything, makes it all make since and really like him, glad I found out about those videos before I started learning as he's a great teacher :P.

Share this post


Link to post
Share on other sites
I haven't watched any of the videos myself, but have heard this from a lot of people I trust to know what they're talking about: just be aware that some of what thenewboston teaches isn't always best practice and might at times include some incorrect or incomplete information. If you're finding the videos helpful continue to use them, just don't take anything as gospel and be sure to continue using other sources as well. LearnCpp.com seems to be a pretty reliable resource if you're looking for another alternative.

Share this post


Link to post
Share on other sites
Here is another helpful couple of resources. The first is an e-book, the second is a university page, and I would say that you could probably safely bet on the university page (Missouri S&T Computer Science Department) being 100% correct.

e-book: http://newdata.box.sk/bx/c/
uni pages: here

Hope this helps, these taught me a lot back when I was starting out with C++.

EDIT: The uni pages ARE videos, if there was any uncertainty. Edited by MrJoshL

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement