vendredi 7 août 2020

Why the variable in lambda is not able to call the function

This is the class.

#include <iostream>
#include <string>

std::string strName = "ABC";

class BlueOut
{
public:
    void printName() { std::cout << strName << std::endl; }

};

Now i create a object of this class

 BlueOut blueout;

And i call the function printName() of the object in lambda

auto a = [&]() { blueout.printName(); };

But the function does not gets executed.

Aucun commentaire:

Enregistrer un commentaire