Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef TEST_H
- #define TEST_H
- class test
- {
- public:
- test();
- int lambda2();
- private:
- int m_i = 4;
- int m_j = 3;
- };
- #endif // TEST_H
- #include "test.h"
- #include <iostream>
- test::test() {
- auto lambda = [this] { return m_i; };
- std::cout << lambda() << std::endl;
- }
- int test::lambda2()
- {
- auto lambda2 = [this](int a) { return m_i + a; };
- std::cout << lambda2(2) << std::endl;
- }
- #include <iostream>
- #include "test.h"
- using namespace std;
- int main()
- {
- int i = 5;
- int j = 6;
- auto p = [&] (int& a , int& b) { cout << a+b << endl; a++; };
- p(i,j); // Appel de la fonction
- cout << i << " " << j << endl;
- test obj1;
- obj1.lambda2();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement