Thread: Pass vector to a function

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    116

    Question Pass vector to a function

    I'm reading how to use STL in C++. And I have read one code:
    Code:
    void functionX(vector<int>&a){
    ......
    //some line of code
    }
    int main(){
         vector<int> b(10);
         functionX(b);
         int c[10];
         functionX(c); //error
         return(0);
    }
    the above code mean functionX will use vector<a> to doing something (and it will not copy another vector-->efficiently purpose) But if I use for array c will meet error. So, my question is: the declare of functionX is especially design just for "vector"?

    thanks
    Last edited by hqt; 09-14-2011 at 04:04 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to declare and pass the vector pointer in c++
    By kapil1089thekin in forum C++ Programming
    Replies: 7
    Last Post: 08-11-2010, 03:09 PM
  2. how to pass a vector to a function
    By chintugavali in forum C++ Programming
    Replies: 8
    Last Post: 12-20-2007, 10:28 PM
  3. How can I define and pass a pointer to a vector object?
    By asmileguo in forum C++ Programming
    Replies: 3
    Last Post: 09-07-2006, 11:19 AM
  4. how would i pass on a vector pointer parameter
    By bugmenot in forum C++ Programming
    Replies: 5
    Last Post: 12-16-2005, 02:51 AM
  5. pass a vector as argument
    By anomaly in forum C++ Programming
    Replies: 3
    Last Post: 12-10-2003, 10:45 AM