L
liam_herron
Any idea why the following code doesn't compile?
#include <iostream>
#include <vector>
class A
{
public:
template<typename T>
void f( const std::vector<T>& v)
{
std::vector<T>::const_iterator it = v.begin();
for (, it != v.end(); ++it)
{
std::cout << *it << std::endl;
}
}
private:
};
--------------------------------------------------------------------------------------------------------------------------------
Compilation Errors:
testVectorIteratorInClass.cpp: In member function `void A::f(const
std::vector<T, std::allocator<_CharT> >&)':
testVectorIteratorInClass.cpp:16: error: expected `;' before "it"
testVectorIteratorInClass.cpp:17: error: expected primary-expression
before ',' token
testVectorIteratorInClass.cpp:17: error: `it' was not declared in this
scope
testVectorIteratorInClass.cpp:17: error: expected `;' before ')' token
#include <iostream>
#include <vector>
class A
{
public:
template<typename T>
void f( const std::vector<T>& v)
{
std::vector<T>::const_iterator it = v.begin();
for (, it != v.end(); ++it)
{
std::cout << *it << std::endl;
}
}
private:
};
--------------------------------------------------------------------------------------------------------------------------------
Compilation Errors:
testVectorIteratorInClass.cpp: In member function `void A::f(const
std::vector<T, std::allocator<_CharT> >&)':
testVectorIteratorInClass.cpp:16: error: expected `;' before "it"
testVectorIteratorInClass.cpp:17: error: expected primary-expression
before ',' token
testVectorIteratorInClass.cpp:17: error: `it' was not declared in this
scope
testVectorIteratorInClass.cpp:17: error: expected `;' before ')' token