请问这两个程序有什么区别?求解
程序1#include <iostream.h>
void Swap(char* str1, char* str2);
void main()
{
char* ap="hello";
char* bp="how are you?";
cout <<ap <<endl <<bp <<endl;
Swap(ap, bp);
cout <<"交换以后:\n";
cout <<ap <<endl <<bp <<endl;
}
void Swap(char* str1, char* str2)
{ char* temp=str1;
str1=str2; str2=temp;
}
程序2
#include <iostream.h>
void Swap(char*& str1, char*& str2);
void main()
{
char* ap="hello";
char* bp="how are you?";
cout <<ap <<endl <<bp <<endl;
Swap(ap, bp);
cout <<"交换以后:\n";
cout <<ap <<endl <<bp <<endl;
}
void Swap(char*& str1, char*& str2)
{ char* temp=str1;
str1=str2; str2=temp;
}