Skip to content
  • Home
  • Android
  • Python
  • C++
  • Java
  • Technology
  • Contact
  • Books
  • Posts

C++ Examples

  1. Write a C++ Program to print a welcome text in a separate line.
  2. Write a Program in C++ to add two numbers.
  3. C++ program for addition of two numbers using functions.
  4. Add two numbers in C++ using class.
  5. Addition of two numbers using call by reference in C++
  6. C++ program to write a program to add two numbers using call by value.
  7. Swapping of two numbers in C++ without using third variable. 
  8. Swap two numbers in C++ using function.
  9. C++ program to swap two numbers using class.
  10. C++ program to swap two numbers using call by value.
  11. C++ program to swap two numbers using pointers.
  12. Write a program to swap private data members of two classes using friend function.
  13. write a program to add data objects of two different classes using friend function.
  14. Threading in C++.
  15. C++ thread lambda
  16. C++ thread lambda with parameter
  17. C++ thread lambda pass by reference
  18. Singleton C++ example

C++ thread lambda pass by reference

 #include <iostream>
 #include <thread>
 
 using namespace std;
 
 int main()
 {
 
    // Variable declaration
    
    int x = 4;
    int y = 5;
    
    //Creation of thread with Lambda expression
    
    thread th1([&x, &y]() {
    cout << x <<endl;
    cout << y <<endl;
        
    });
    
    //thread joining
    
    th1.join();
        
    cout << x <<endl;
    cout << y <<endl;
        
    return 0;
  }

Output

4
5
4
5
Subscribe
Notify of
guest
guest
0 Comments
Oldest
Newest Most Voted
Copyright © 2026 Coddesire Powered by Coddesire
wpDiscuz