#include<algorithm>
#include<string>
#include<vector>
#include<functional>
#include<iostream>
using namespace std;
class WordCompare:binary_function<string,string,bool>
{
public:
	bool operator()(const string&a ,const string& b)
	{
		if(a.at(0)==b.at(0))
			return true;
		else 
			return false;
	}
};
int main()
{
	vector<string>MainText;
	vector<string>TempString;
	vector<string>::iterator i;
	MainText.push_back("All");
	MainText.push_back("art");
	MainText.push_back("is");
	MainText.push_back("quite");
	MainText.push_back("useless");
	TempString.push_back("quite");
	TempString.push_back("unique");
	i=search (MainText.begin(),MainText.end(),TempString.begin(),
		TempString.end(),WordCompare());
		if(i==MainText.end())
			cout<<"The substring is not found"<<endl;
		else
			cout<<"The substring is found"<<endl;
		return 0;
}

why there should have a class definition?
is that the definition style of any function object?

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.