Wednesday, August 3, 2022

CALL BY REFERENCE

 #include<iostream>

using namespace std;


void swap(int &a,int &b)

{

    cout<<&a<<" "<<&b;

    int temp;

    temp=a;

    a=b;

    b=temp;

}


int main()

{

    int x=10; int y=20;

    swap(x,y);

    cout<<&x<<" "<<&y<<endl;

    cout<<x<<" "<<y<<endl;

}

No comments:

Post a Comment

CONSTRUCTURE IN PARENT CLASS

class Parent {     public Parent()     {         System.out.println("Parent Constrcutor");     }              } class Child extend...