I am trying to use the for_each from stl algorithm.
http://www.cplusplus.com/reference/algorithm/for_each.html

#include <algorithm>
#include <vector>
#include <iostream>

	template <typename T>
	void OutputObject(const T &obj)
	{
		cout << obj << endl;
	}
	
	template <typename T>
	void OutputVector(const vector<T> &V)
	{
		for_each (V.begin(), V.end(), OutputObject);
		cout << endl;
	}

I get "no matching function call to for_each". Why would that be?

Thanks,
Dave

You need to instantiate the OutputObject template: for_each (V.begin(), V.end(), OutputObject<T>);

ah cool. thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.