哪位大侠帮我看看我的程序哪里错了?在VC++6.0上编译总是有一个错误。。。

2025-03-05 09:22:52
推荐回答(1个)
回答1:

建议用指针

我给你重写了

// temp.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
using namespace std;
template //模版
void swap(T *a,T *b) //交换函数
{
T *temp;
temp = a;
a = b;
b = temp;
}
void show(int a,int b) //显示函数
{
cout<<"i = "<cout<<"j = "<}
int main() //主函数
{
int i = 11,j = 22;
cout<<"交换前:"<show(i,j); //显示交换前i和j
swap(i,j); //交换i和j
cout<<"交换后:"<show(i,j); //显示交换后i和j
return 0;
}