-
Notifications
You must be signed in to change notification settings - Fork 935
Closed
Description
Dear Federico,
perhaps an error in 05.Basic_Concepts_IV.pdf
slide 33.
auto lambda3 = [this]() { return data; }; // copy by-reference, return 2
it returns 1, not 2.
For instance, the following prints 1 with -std=c++20
:
#include <iostream>
class A {
public:
int data = 1;
void f(){
int var = 2;
auto lambda3 = [this](){return data;};
std::cout<<lambda3()<<std::endl;
}
};
int main(){
A a;
a.f();
return 0;
}
Metadata
Metadata
Assignees
Labels
No labels