I have not used an object to call the function but have passed objects as parameters and call function without an object. Can anyone explain
#include <iostream>
using namespace std;
class test
{ int a;
public:
test(int x): a(x) {}
void display()
{
cout<<"the value of a is"<<a<<endl;
}
void swap(test &t, test &t1)
{
test tmp( t1 );
t1 = t;
t = tmp;
}
};
int main()
{
test t(20), t1(30);
swap(t,t1);
t.display();
t1.display();
return 0;
}