Selamün Aleyküm;
Kod şöyle:
#include <iostream>
using namespace std;
class Example
{
private:
std::string str;
public:
Example();
void foo()
{
[]()
{
str = "Hello World!\n";
};
}
void print() const
{
cout << str << endl;
}
};
int main()
{
Example e;
e.foo();
e.print();
return 0;
}
Ve şu hatayı alıyorum:
/home/UserName/My Projects/cppproject1/main.cpp:15: error: 'this' was not captured for this lambda function
str = "Hello World!\n";
^
Bu şekilde sınıf verisi olan str'ye nasıl ulaşabilirim? (Yani şöyle: { str = "Hello"; }).
Teşekkürler.
--
[ Bu gönderi, http://ddili.org/forum'dan dönüştürülmüştür. ]
Permalink
Reply