Hello All,
Are C++ vectors the same as the vectors in maths?
A vector has a size and magnitude, is a C++ vector like this? I had some trouble with C++ vectors and the ideas behind them.
Thanks.
8 replies to this topic
#1
Posted 25 June 2010 - 10:43 PM
|
|
|
#2
Posted 25 June 2010 - 11:01 PM
Vectors are like arrays. If you haven't already looked at this, it contains code too. C++ Reference - vector
Something witty here.
#3
Posted 26 June 2010 - 01:08 AM
So it's not like the vectors in mathematics? (Size and magnitude-e.g. Speed).
#4
Posted 26 June 2010 - 02:54 AM
Hunter100 said:
So it's not like the vectors in mathematics? (Size and magnitude-e.g. Speed).
Nope, There are such things as synonyms you know.
Regardless, In the English language; vector: a variable quantity that can be resolved into components.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#5
Posted 26 June 2010 - 05:21 PM
Oh okay thanks again nullw0rm your really helpful.
#6
Posted 27 June 2010 - 10:32 AM
Quote
Vectors are like arrays. If you haven't already looked at this, it contains code too. C++ Reference - vector
A vector in C++ is only a container. A vector can contain any data type. Vector's are apart of the STL (Standard Template Library).
A vector has predefined methods (functions) which can operate on the data, which make it very useful in some cases.
Unlike predefined arrays, vector's are dynamic, which means they can grow, or shrink as needed.
There are many more benefits to using vectors over arrays in certain cases; Not that you shouldn't ever use an array.
“You may be disappointed if you fail, but you are doomed if you don't try.”
- Beverly Sills
- Beverly Sills
#7
Posted 27 June 2010 - 12:17 PM
Muted said:
A vector in C++ is only a container. A vector can contain any data type. Vector's are apart of the STL (Standard Template Library).
A vector has predefined methods (functions) which can operate on the data, which make it very useful in some cases.
Unlike predefined arrays, vector's are dynamic, which means they can grow, or shrink as needed.
There are many more benefits to using vectors over arrays in certain cases; Not that you shouldn't ever use an array.
A vector has predefined methods (functions) which can operate on the data, which make it very useful in some cases.
Unlike predefined arrays, vector's are dynamic, which means they can grow, or shrink as needed.
There are many more benefits to using vectors over arrays in certain cases; Not that you shouldn't ever use an array.
That's why I said "like arrays". :)
Something witty here.
#8
Posted 27 June 2010 - 04:11 PM
Oh, so they can be resized as needed, but is that dependent upon the amount of data inputted or just the programmer?
#9
Posted 27 June 2010 - 08:50 PM
Hunter100 said:
Oh, so they can be resized as needed, but is that dependent upon the amount of data inputted or just the programmer?
No, it is not dependent upon the 'amount of data inputted.'
You can set the vectors size to an exact specification if you wish.
Link: resize - C++ Reference
“You may be disappointed if you fail, but you are doomed if you don't try.”
- Beverly Sills
- Beverly Sills
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









