I am continuing my studies of C++ and I came across lambdas. I am following a simple tutorial just to get a feel for the sintax, but the following code is failing:
#include "stdafx.h" #include <string> #include <iostream> using namespace std; void runDivide(double (*divide)(double a, double b)) { auto rval = divide(a , b); cout << rval << endl; } int main() { auto funcDiv = [](double value1, double value2) -> double{ if (value2 == 0.0) { return 0; } return value1 / value2; }; runDivide(funcDiv); system("pause"); return 0; } This is giving me a "Identifier 'a' is undefined" and "Identifier 'b' is undefined". Although I am copying it verbatin from the tutorial, maybe I'm missing something?
Thanks in advance for the help!
Michael
aandbinrunDivide().aandbaren't defined anywhere. They're simply in the type of the function pointer.