vectors

This is a discussion on vectors within the C++ Programming forums, part of the General Programming Boards category; very confused on how to use vectors to display a matrix. Can any help with some code to start? template<class ...

  1. #1
    Unregistered
    Guest

    Question vectors

    very confused on how to use vectors to display a matrix. Can any help with some code to start?

    template<class t>class vector

    not sure what to do after this?

    HELP!!!!!

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    13
    Ok, I'm not sure what it is you wan't help with.. displaying the content of a vector? / a 2D vector? or just generaly how a vector works?

    Here is a smal example:

    #include <vector>

    ostream& operator<<(ostream& out, const vector<int>& v) {
    copy(v.begin(), v.end(), ostream_iterator<int>(out," "));
    return out;
    }

    int main(void) {
    // create a vector of double's, and one of int's
    vector<int> vi;

    // insert values before the beginning
    for(int i = 0; i < 10; ++i) {
    vi.insert(vi.begin(), i);
    }

    // print out the vector
    cout << vi << endl;

    return 0;
    }

    I'm not sure how to create a 2D(/matrix) vector .. perhaps this works:
    vector<vector<sometype>> v;

    - Anders

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Vectors
    By naseerhaider in forum C++ Programming
    Replies: 11
    Last Post: 05-09-2008, 09:21 AM
  2. How can i made vectors measuring program in DevC++
    By flame82 in forum C Programming
    Replies: 1
    Last Post: 05-07-2008, 03:05 PM
  3. How properly get data out of vectors of templates?
    By 6tr6tr in forum C++ Programming
    Replies: 4
    Last Post: 04-15-2008, 11:35 AM
  4. How to use Vector's in C++ !?!
    By IndioDoido in forum C++ Programming
    Replies: 3
    Last Post: 10-14-2007, 12:13 PM
  5. Points, vectors, matrices
    By subnet_rx in forum Game Programming
    Replies: 17
    Last Post: 01-11-2002, 02:29 PM

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