What is a vector? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

What is a vector?

bluj91bluj91 Posts: 133Member
Hello, I was wondering, what is the operators <> used for in standard C++. I ask this because I wasn't aware that such an operator existed outside that visual C++, where it is used to declare an array. Futhermore, what is a vector? You see there's gaps in what I know of C++ due to simply migrated from C. Rather than studying the language as a whole.

Cheers

Comments

  • LundinLundin Posts: 3,711Member
    : Hello, I was wondering, what is the operators <> used for in standard C++. I ask this because I wasn't aware that such an operator existed outside that visual C++, where it is used to declare an array. Futhermore, what is a vector? You see there's gaps in what I know of C++ due to simply migrated from C. Rather than studying the language as a whole.
    :
    : Cheers
    :


    "Vector" is probably the most vauge term used in programming...
    In C++, vector is a standard container class for arrays. <> is not an operator but the syntax used for templates:

    vector x; // create a vector for integers.


  • bilderbikkelbilderbikkel Posts: 754Member
    : Hello, I was wondering, what is the operators <> used for in standard C++. I ask this because I wasn't aware that such an operator existed outside that visual C++, where it is used to declare an array. Futhermore, what is a vector? You see there's gaps in what I know of C++ due to simply migrated from C. Rather than studying the language as a whole.

    See www.codepedia.com/1/CppVector and www.codepedia.com/1/CppTemplate.
    See ya,
    bilderbikkel

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : Hello, I was wondering, what is the operators <> used for in standard C++. I ask this because I wasn't aware that such an operator existed outside that visual C++, where it is used to declare an array. Futhermore, what is a vector? You see there's gaps in what I know of C++ due to simply migrated from C. Rather than studying the language as a whole.
    :
    : Cheers
    :
    [blue]Vector is an array of elements, like someone said here. However, the implementation of it is a linked list - nightmare, in other words. I stopped using vectors long ago - a simple growable array is better in my opinion. I agree, that implementation is compiler dependant, but all compilers, for some reason making a linked lists as vectors.[/blue]
  • bilderbikkelbilderbikkel Posts: 754Member
    : [blue]Vector is an array of elements, like someone said here. However, the implementation of it is a linked list - nightmare, in other words. I stopped using vectors long ago - a simple growable array is better in my opinion. I agree, that implementation is compiler dependant, but all compilers, for some reason making a linked lists as vectors.[/blue]

    Hi AsmGuru,

    the implementation of a std::vector is NOT of a linked list, a std::list is. A std::vector is guaranteed to have the same layout in memory as an array, for backwards compatibilty with C.

    See Scott Meyers article (http://www.artima.com/cppsource/top_cpp_books.html) to say that he regrets that this is not clearly reported in the Standard yet.

    See ya,

    bilderbikkel

Sign In or Register to comment.