📄 15-07-03.cpp
字号:
#include <iostream>#include <functional>#include <iterator>#include <algorithm>#include <vector>using namespace std;struct Operation { virtual double eval(double) = 0;};struct Square : public Operation { double eval(double x) { return x * x; }};struct Negate : public Operation { double eval(double x) { return -x; }};int main(){ vector<Operation*> operations; vector<double> operands; operations.push_back(new Square); operations.push_back(new Square); operations.push_back(new Negate); operations.push_back(new Negate); operations.push_back(new Square); operands.push_back(1); operands.push_back(2); operands.push_back(3); operands.push_back(4); operands.push_back(5); transform(operations.begin(), operations.end(), operands.begin(), ostream_iterator<double>(cout, "\n"), mem_fun(&Operation::eval));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -