can we create instance of a vector?

This is a discussion on can we create instance of a vector? within the C++ Programming forums, part of the General Programming Boards category; can we create instance of a vector?...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    78

    can we create instance of a vector?

    can we create instance of a vector?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,647
    Yes, obviously, if we're talking about std::vector.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Creating an instance of a vector as opposed to doing what else with it?

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    78
    ya i was talikg about std:vector

    i know this question may sound silly to you but i am a begineer!

  5. #5
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,799
    The whole STL would be rather meaningless if we couldn't instantiate any of the containers/objects that are described within it.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  6. #6
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Since std::vector is a template, you need to specify a type to create an instance of it. eg.
    Code:
    std::vector<int> intVec;

  7. #7
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. easiest way of writing all the contents of
    By stanlvw in forum C++ Programming
    Replies: 2
    Last Post: 03-31-2009, 01:09 PM
  2. Vectors
    By naseerhaider in forum C++ Programming
    Replies: 11
    Last Post: 05-09-2008, 08:21 AM
  3. vector of arrays of pointers to structures
    By Marksman in forum C++ Programming
    Replies: 13
    Last Post: 02-01-2008, 03:44 AM
  4. my vector class..easy dynamic arrays
    By nextus in forum C++ Programming
    Replies: 5
    Last Post: 02-03-2003, 09:14 AM
  5. Operators for 3D Vector Mathematics
    By Anarchist in forum C++ Programming
    Replies: 10
    Last Post: 01-31-2003, 06:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21