Let's suppose I have a function as follows:
#include<iostream>
int func(int a, int b)
{
return a+b;
}
Without using an if else construct, suppose I want to generalize this function to take in an operator "-" that allows me to return a-b , is there a way for me to do it?
I came across the following link with regard to C and thought it would be a good idea to know if there are any new features in C++ that make this a little easier?
In addition, is there a way for me to store an operator in a variable or pass a reference to it?
Aucun commentaire:
Enregistrer un commentaire