What are vectors?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2007
Posts: 126
Reputation: krnekhelesh is an unknown quantity at this point 
Solved Threads: 3
krnekhelesh's Avatar
krnekhelesh krnekhelesh is offline Offline
Junior Poster

What are vectors?

 
0
  #1
Jul 11th, 2007
I read that vectors and arrays are almost the same. Could you explain this to me?
Ubuntu Linux User #25732
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: What are vectors?

 
0
  #2
Jul 11th, 2007
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 126
Reputation: krnekhelesh is an unknown quantity at this point 
Solved Threads: 3
krnekhelesh's Avatar
krnekhelesh krnekhelesh is offline Offline
Junior Poster

Re: What are vectors?

 
0
  #3
Jul 11th, 2007
ok they are resizable array! That's good, I mean instead of just creating a big array and wasting memory we can use vectors.

Can we drop the .h from all the C++ headers? But it works for me even though I use them.
Ubuntu Linux User #25732
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 759
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Solved Threads: 35
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

Re: What are vectors?

 
1
  #4
Jul 11th, 2007
vectors are much like arrays

  1. #include <vector>
  2. int main()
  3. {
  4. //standard way to create an array
  5. int myarray[someconstsize] = { 0 }; //assigns all values to default zero
  6.  
  7. //vector declaration
  8. vector<int> myvec;//declares an int type vector
  9.  
  10. //adding data to them
  11.  
  12. myarray[0] = 4;
  13.  
  14. myvec.push_back(4); //adds four to the end

this is in no ways the end all be all deffination, but a somewhat decent look at em
Dont forget to spread the reputation to those that deserve!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: What are vectors?

 
0
  #5
Jul 11th, 2007
I'm not even sure you can use stl stuff in turbo c. (old one that it).

When you finish your edjumacation and if you want to learn proper c++, get dev-cpp from bloodshed.
Last edited by iamthwee; Jul 11th, 2007 at 6:03 am.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 126
Reputation: krnekhelesh is an unknown quantity at this point 
Solved Threads: 3
krnekhelesh's Avatar
krnekhelesh krnekhelesh is offline Offline
Junior Poster

Re: What are vectors?

 
0
  #6
Jul 11th, 2007
I have dev-c++ but I didn't use it because it didn't support graphics
Ubuntu Linux User #25732
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 759
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Solved Threads: 35
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

Re: What are vectors?

 
0
  #7
Jul 11th, 2007
Originally Posted by krnekhelesh View Post
I have dev-c++ but I didn't use it because it didn't support graphics
could always work with Visual Studio

i happen to find this environment quite fun and easy to work in.
Dont forget to spread the reputation to those that deserve!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: What are vectors?

 
0
  #8
Jul 11th, 2007
Dev is better for pure c++, VS tends to convolute what is standard c++. Such as when killer typo mistook

  1. for each

As standard c++.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 759
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Solved Threads: 35
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

Re: What are vectors?

 
0
  #9
Jul 11th, 2007
Originally Posted by iamthwee View Post
Dev is better for pure c++, VS tends to convolute what is standard c++. Such as when killer typo mistook

  1. for each

As standard c++.
heh it's actually because of a setting in VS which can be turned off to disable

dont try and set the standard with my mistake that would be a mistake in itself

i've asked a couple professionals (30+ years experience in software/hardware..etc development, one of which is currently head of product research development) and when i asked about the compiler they use, they replied that they use microsofts products.

when i asked about other compilers, like borland, turbo, bloodshed they just laughed them off.
Last edited by Killer_Typo; Jul 11th, 2007 at 6:23 am.
Dont forget to spread the reputation to those that deserve!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: What are vectors?

 
0
  #10
Jul 11th, 2007
Nah, VS is too bloated and c++.net is horrible.

For pure c++. i.e no windows GUI crap, you don't need Visual Studio.

And anyway, if you are writing code it is best to test it with different compilers and operating systems to ensure portability.
Last edited by iamthwee; Jul 11th, 2007 at 6:27 am.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC