Adding vectors ??

This is a discussion on Adding vectors ?? within the C++ Programming forums, part of the General Programming Boards category; When i last time tried to add vectors i got nasty error (in dev-c++) that opens another file .cpp and ...

  1. #1
    "Why use dynamic memory?"
    Join Date
    Aug 2006

    Adding vectors ??

    When i last time tried to add vectors i got nasty error (in dev-c++) that opens another file .cpp and cite the error, a line that has some iterator.

    this is the code

    #include <iostream>
    #include <vector>
    using namespace std;
    int main()
    	//Making vectors 
    	vector<string> my;
    	vector<string> yours;
    	vector<string> ours(my, yours);
    	return 0;

    plz tell me how to add more than one vector (for example 5 vectors) in one vector ? do i have to specify the size of the vector that is having all the vectors ??

    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
    Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Assuming that you want to combine the two vectors, it would be something like:
    vector<string> ours(my);
    ours.insert(ours.end(), yours.begin(), yours.end());
    If you want to create a vector of vectors, then it would be:
    vector<vector<string> > ours;
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can i made vectors measuring program in DevC++
    By flame82 in forum C Programming
    Replies: 1
    Last Post: 05-07-2008, 02:05 PM
  2. How properly get data out of vectors of templates?
    By 6tr6tr in forum C++ Programming
    Replies: 4
    Last Post: 04-15-2008, 10:35 AM
  3. Adding Vectors
    By Tonto in forum Game Programming
    Replies: 5
    Last Post: 11-20-2006, 12:06 AM
  4. SVN Import Causes Crash
    By Tonto in forum Tech Board
    Replies: 6
    Last Post: 11-01-2006, 02:44 PM
  5. adding vectors
    By sdchem in forum C++ Programming
    Replies: 2
    Last Post: 04-22-2003, 11:34 AM

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