How to bind multiplies<int> and multiplies<int> and make calculation in C++

1 Answer

0 votes
#include <iostream>
#include <functional>

using std::cout;
using std::endl;

int main()
{
	auto pow3 = std::bind(std::multiplies<int>(),
		                  std::bind(std::multiplies<int>(),
			                        std::placeholders::_1, std::placeholders::_1), 
		                  std::placeholders::_1);

	cout << pow3(2) << endl;
	cout << pow3(3) << endl;
	cout << pow3(4) << endl;
}

/*
run:

8
27
64

*/

 



answered Jan 26, 2018 by avibootz

Related questions

1 answer 194 views
1 answer 163 views
1 answer 154 views
1 answer 178 views
...