+ Reply to Thread
Results 1 to 2 of 2

Thread: What is class function object?

  1. #1

    What is class function object?

    Hi All,

    What is class function object?

    Regards.

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Posts
    109
    Hi,

    Class function object is create a class with 'call' operator.

    Below example shows how to create this:

    Code:
    class CIndexing
    {
    public:
    	void operator ()(int nIndex) const
    	{
    		printf("nIndex = %d\n", nIndex) ;
    	}
    } ;
    
    void UseFunctionObject()
    {
    
    	std::vector<int> vInts ;
    	
    	for(int i=0; i<3; i++)
    	{
    		vInts.push_back(i) ;
    	}
    
    	std::for_each(vInts.begin(), vInts.end(), CIndexing()) ;
    }
    Regards.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts