What are namespaces, functors, and iterator classes in C++?

(Last Updated On: May 17, 2010)

What are namespaces, functors, and iterator classes in C++?
Namespaces reduced name collisions where an application may have various libraries of the same name. The using declaration makes it possible for a namespace without using a scope operator.
There are five types of iterator classes which input iterators, output iterators, forward iterators, and bidirectional iterators. These are usually stored in stored in lists and queues according to some ordering relation as defined in a binary tree.
Functors are a function pointer which holds the address of some pointer.
using namespace std;

class Matcher
int target;
Matcher(int m) : target(m) {}
int operator()(int x) { return x == target;}

int main() {
Matcher Is5(5);
int n=6;

if (Is5(n)) { // same as if (n == 5) return 0;
cout << "n and Is5 are equal" << endl; } else { cout << "not equal"< NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Subscribe For Latest Updates

Sign up to best of business news, informed analysis and opinions on what matters to you.
Invalid email address
We promise not to spam you. You can unsubscribe at any time.


Check NEW site on stock forex and ETF analysis and automation

Scroll to Top