943,917 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3337
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Jul 11th, 2007
0

What are vectors?

Expand Post »
I read that vectors and arrays are almost the same. Could you explain this to me?
Similar Threads
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Jul 11th, 2007
0

Re: What are vectors?

Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Jul 11th, 2007
0

Re: What are vectors?

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.
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Jul 11th, 2007
1

Re: What are vectors?

vectors are much like arrays

C++ Syntax (Toggle Plain Text)
  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
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004
Jul 11th, 2007
0

Re: What are vectors?

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.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Jul 11th, 2007
0

Re: What are vectors?

I have dev-c++ but I didn't use it because it didn't support graphics
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Jul 11th, 2007
0

Re: What are vectors?

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.
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004
Jul 11th, 2007
0

Re: What are vectors?

Dev is better for pure c++, VS tends to convolute what is standard c++. Such as when killer typo mistook

C++ Syntax (Toggle Plain Text)
  1. for each

As standard c++.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Jul 11th, 2007
0

Re: What are vectors?

Click to Expand / Collapse  Quote originally posted by iamthwee ...
Dev is better for pure c++, VS tends to convolute what is standard c++. Such as when killer typo mistook

C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004
Jul 11th, 2007
0

Re: What are vectors?

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.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Help with 'for' loops and formatting using printf
Next Thread in C++ Forum Timeline: Reading multiple lines from a txt file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC