N
nguyen.h.khanh
Hi,
I have this code
#include <vector>
#include <string>
#include <iostream>
using namespace std;
template <class T> void print_list(const vector<T>& v){
typedef typename vector<T>::iterator i;
for (i = v.begin();i != v.end(); ++i)
cout << (*i) << " ";
cout << endl;
}
int main(){
vector<int> l(5,1);
print_list(l);
return 0;
}
when i tried to compile, it gave
ch3list.cpp: In function `void print_list(const std::vector<T,
std::allocator<_C
harT> >&)':
ch3list.cpp:11: error: expected primary-expression before '=' token
ch3list.cpp:11: error: expected primary-expression before '!=' token
ch3list.cpp:11: error: expected primary-expression before ')' token
ch3list.cpp:12: error: expected primary-expression before ')' token
what did I do wrong here?
Many thanks,
-k
I have this code
#include <vector>
#include <string>
#include <iostream>
using namespace std;
template <class T> void print_list(const vector<T>& v){
typedef typename vector<T>::iterator i;
for (i = v.begin();i != v.end(); ++i)
cout << (*i) << " ";
cout << endl;
}
int main(){
vector<int> l(5,1);
print_list(l);
return 0;
}
when i tried to compile, it gave
ch3list.cpp: In function `void print_list(const std::vector<T,
std::allocator<_C
harT> >&)':
ch3list.cpp:11: error: expected primary-expression before '=' token
ch3list.cpp:11: error: expected primary-expression before '!=' token
ch3list.cpp:11: error: expected primary-expression before ')' token
ch3list.cpp:12: error: expected primary-expression before ')' token
what did I do wrong here?
Many thanks,
-k