Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualDan Mayor

Posted 12 January 2013 - 12:09 PM

As a bit of a side note, C++ is one of if not the most complex languages in the programming field.  I just wanted to comment on the statement that you'r not quite sure where things would actually fit in practical application yet.  From my experience and through watching associates who have learned (or attempted to learn) the language 100 pages is no where near enough to start making these conclusions yet.

 

Since C++ is so vast and open it leads to there being dozens if not hundreds of different ways that you can get to the same solution.  As such it normally requires an entire book (or two) just to get your feet wet and get started with the language.  However you should be starting to have some ideas as to what's what by now assuming that you have actually been working the tutorials and "assignments" of the book you are reading.  That is to say that most of the books I've read will teach you something, then demonstrate how to use it with code examples and ask you to code along.  Are you doing these code examples or are you just browsing through them and moving on?

 

I don't want to jump to conclusions but it sounds partially like maybe you are moving faster than you should be.  If your confusion is on things prior to where you are in your book (eg you didn't completely understand something but moved on anyway) your on a suicide path.  Go back, rework all of the examples, do the "suggested assignment's" if they offer them.  If your still confused meet Google and look up more reading information.

 

If you are partially through a section and it does not make sense just yet it may not be that bad just yet.  Some things such as dynamic collections (vector's, deques and so on) are pretty difficult to wrap your head around and can take a good 100 pages themselves to learn.  The key on these things is just to remember it is a collection of values.  The core things you should understand completely before attempting to learn these is variables, data types and arrays.  If you are not familiar with these go back and study until you are, when you come back it will make more sense.

 

To address the sudo question I noticed in your post (what is a vector used for).  It's used to store a collection of values where in you do not have a limited number of said values.  It is basically used interchangeably with array's.  Where you might use an array to store a list of product id's, you would use a vector to store a list of product id's that can grow and shrink as needed.  Example, you are making a simple catalog for 100 products and you will never ever add or remove products from this catalog.  You would use an array of integers.  In real life when you make a catalog you know that you may be adding or removing products as time goes on.  Instead of making a huge array and trying to manage all 1 million pieces of this array every time you add or remove a product you would choose a vector which can automatically increase it's number or elements as you add more to it (and "plug holes" as it where when you remove items).

 

To relate this to game development application get's a bit trickier (and I hope you have an understanding of classes and objects already to understand this answer).  A vector is commonly used in game development to hold a collection of the NPC objects of a level.  This is so when you create a level class and have it load a file, you can have it also load a collection of NPC's for that level.  If level 1 has 3 NPC's your Vector will have 3 elements.  If level 10 has 100 NPC's your vector would have 100 elements.  Using a standard array you would have to create it to be at least 100 elements to support level 10, in level 1 you are wasting 97 sections of memory on unused reservations for those NPC's that don't even exist.

 

(P.S. an array isn't the best way to describe a vector but I'm assuming that you did not learn about linked lists and I'm simply trying to relate to knowledge that I assume you already have, if you HAVE learned linked lists then that is actually what the vector is.  A linked list of elements that contain the variables as defined by the template type cast of the vector <thing here>.)


#1Dan Mayor

Posted 12 January 2013 - 12:05 PM

As a bit of a side note, C++ is one of if not the most complex languages in the programming field.  I just wanted to comment on the statement that you'r not quite sure where things would actually fit in practical application yet.  From my experience and through watching associates who have learned (or attempted to learn) the language 100 pages is no where near enough to start making these conclusions yet.

 

Since C++ is so vast and open it leads to there being dozens if not hundreds of different ways that you can get to the same solution.  As such it normally requires an entire book (or two) just to get your feet wet and get started with the language.  However you should be starting to have some ideas as to what's what by now assuming that you have actually been working the tutorials and "assignments" of the book you are reading.  That is to say that most of the books I've read will teach you something, then demonstrate how to use it with code examples and ask you to code along.  Are you doing these code examples or are you just browsing through them and moving on?

 

I don't want to jump to conclusions but it sounds partially like maybe you are moving faster than you should be.  If your confusion is on things prior to where you are in your book (eg you didn't completely understand something but moved on anyway) your on a suicide path.  Go back, rework all of the examples, do the "suggested assignment's" if they offer them.  If your still confused meet Google and look up more reading information.

 

If you are partially through a section and it does not make sense just yet it may not be that bad just yet.  Some things such as dynamic collections (vector's, deques and so on) are pretty difficult to wrap your head around and can take a good 100 pages themselves to learn.  The key on these things is just to remember it is a collection of values.  The core things you should understand completely before attempting to learn these is variables, data types and arrays.  If you are not familiar with these go back and study until you are, when you come back it will make more sense.

 

To address the sudo question I noticed in your post (what is a vector used for).  It's used to store a collection of values where in you do not have a limited number of said values.  It is basically used interchangeably with array's.  Where you might use an array to store a list of product id's, you would use a vector to store a list of product id's that can grow and shrink as needed.  Example, you are making a simple catalog for 100 products and you will never ever add or remove products from this catalog.  You would use an array of integers.  In real life when you make a catalog you know that you may be adding or removing products as time goes on.  Instead of making a huge array and trying to manage all 1 million pieces of this array every time you add or remove a product you would choose a vector which can automatically increase it's number or elements as you add more to it (and "plug holes" as it where when you remove items).

 

To relate this to game development application get's a bit trickier (and I hope you have an understanding of classes and objects already to understand this answer).  A vector is commonly used in game development to hold a collection of the NPC objects of a level.  This is so when you create a level class and have it load a file, you can have it also load a collection of NPC's for that level.  If level 1 has 3 NPC's your Vector will have 3 elements.  If level 10 has 100 NPC's your vector would have 100 elements.  Using a standard array you would have to create it to be at least 100 elements to support level 10, in level 1 you are wasting 90 sections of memory on unused reservations for those NPC's that don't even exist.

 

(P.S. an array isn't the best way to describe a vector but I'm assuming that you did not learn about linked lists and I'm simply trying to relate to knowledge that I assume you already have, if you HAVE learned linked lists then that is actually what the vector is.  A linked list of elements that contain the variables as defined by the template type cast of the vector <thing here>.)


PARTNERS