954,224 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

What are vectors?

I read that vectors and arrays are almost the same. Could you explain this to me?

krnekhelesh
Junior Poster
127 posts since Jul 2007
Reputation Points: 31
Solved Threads: 3
 
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

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.

krnekhelesh
Junior Poster
127 posts since Jul 2007
Reputation Points: 31
Solved Threads: 3
 

vectors are much like arrays

#include <vector>
int main()
{
//standard way to create an array
int myarray[someconstsize] = { 0 }; //assigns all values to default zero
 
//vector declaration
vector<int> myvec;//declares an int type vector
 
//adding data to them
 
myarray[0] = 4;
 
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 :)

Killer_Typo
Master Poster
781 posts since Apr 2004
Reputation Points: 152
Solved Threads: 39
 

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.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

I have dev-c++ but I didn't use it because it didn't support graphics

krnekhelesh
Junior Poster
127 posts since Jul 2007
Reputation Points: 31
Solved Threads: 3
 
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.

Killer_Typo
Master Poster
781 posts since Apr 2004
Reputation Points: 152
Solved Threads: 39
 

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

for each

As standard c++.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

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

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.

Killer_Typo
Master Poster
781 posts since Apr 2004
Reputation Points: 152
Solved Threads: 39
 

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.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

ok what are you two arguing for. I have neither VC++ nor Bloodshed. BORLAND C++ is the best!!

krnekhelesh
Junior Poster
127 posts since Jul 2007
Reputation Points: 31
Solved Threads: 3
 
ok what are you two arguing for. I have neither VC++ nor Bloodshed. BORLAND C++ is the best!!



hehehe i think you win :)

look up the sexually transmitted library (STL)

and the namspace std

along with vectors

very good read and you will learn much in doing so.

the standard template library introduces a lot of functionality. http://www.sgi.com/tech/stl/stl_introduction.html

Killer_Typo
Master Poster
781 posts since Apr 2004
Reputation Points: 152
Solved Threads: 39
 

> BORLAND C++ is the best!!
'Created a game using C++ and OpenGL' is much better thing to write on your resume than 'Created a game using Borland C++'.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733
 

>I have neither VC++ nor Bloodshed. BORLAND C++ is the best!!

That's because you are in a school being taught by clowns. :D

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

>I have neither VC++ nor Bloodshed. BORLAND C++ is the best!!

That's because you are in a school being taught by clowns. :D


You sure about that? Because you are arguing about compilers when the topic posted isWhat are vectors?

So whos being kiddish?

krnekhelesh
Junior Poster
127 posts since Jul 2007
Reputation Points: 31
Solved Threads: 3
 

> You sure about that? Because you are arguing about compilers when the topic posted is What are vectors?

Borland, Visual studio and dev-cpp are not compilers.

:D

And the argument is relevant because a lot of the code you write in the crusty old turbo c will not support what is standard c++. That may include std::vectors.

:D

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

you can't even understand what I meant by compilers and besides since I am just learning vectors I wouldn't start of with std::vectors.

I mean I will just start with declaring vectors and accessing vector member that's it, and I am sure that turbo c++ would support that.

Who told you I am using turbo c++ ? I am using borland C++ 5.5. And for your information that is not old.

krnekhelesh
Junior Poster
127 posts since Jul 2007
Reputation Points: 31
Solved Threads: 3
 

So you are telling that arguing about whether to use dev c++ or VC++ has got everything to do with the topic WHAT ARE VECTORS?

If they are to you then I think you don't understand English.

krnekhelesh
Junior Poster
127 posts since Jul 2007
Reputation Points: 31
Solved Threads: 3
 

So you are telling that arguing about whether to use dev c++ or VC++ has got everything to do with the topic WHAT ARE VECTORS?

If they are to you then I think you don't understand English.

Did you read the replies you got at the beginning of the thread? Your question was answered there - If you need a more detailed explanation than the one you recieved, then you need to ask a more specific question

The compiler discussion has been brought about by the fact that your ancient old Turbo C++ compiler doesn't support many modern C++ language features, vectors likely being one of these features.

Bench
Posting Pro
577 posts since Feb 2006
Reputation Points: 307
Solved Threads: 63
 

Did you read the replies you got at the beginning of the thread? Your question was answered there - If you need a more detailed explanation than the one you recieved, then you need to ask a more specific question

The compiler discussion has been brought about by the fact that your ancient old Turbo C++ compiler doesn't support many modern C++ language features, vectors likely being one of these features.

Never in this topic have I mentioned that I use Turbo C++. Please read the topic fully before posting!

Thank you

krnekhelesh
Junior Poster
127 posts since Jul 2007
Reputation Points: 31
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You