How to write a system verilog function to swap two class objects using pass by reference?

In reply to hkc:

Why not declare the temp variable in the function?