0

Hi guys,

Could you tell me what's wrong with this code? I don't get why the compiler says it can't find a matching function...

#include <iostream>
#include <vector>
using namespace std;

template <class T>
int printVector(vector<T> &x){
    for(unsigned int col = 0; col < x.size(); col++){
        cout << x[col] << " ";
    }
    cout << endl;

    return 0;
}

int main(){
    vector<int> x;
    x.resize(10, 100);
    printVector(&x);

    return 0;
}

Errors:

C:\Code\TEMP\main.cpp||In function `int main()':|
C:\Code\TEMP\main.cpp|28|error: no matching function for call to `printVector(std::vector<int, std::allocator<int> >*)'|
||=== Build finished: 1 errors, 0 warnings ===|
2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Clockowl
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.