gpt4 book ai didi

c++ - 我正在尝试在 C++ 中使用模板

转载 作者:太空宇宙 更新时间:2023-11-04 15:34:46 25 4
gpt4 key购买 nike

<分区>

#include <iostream>
using namespace std;
template <typename T>
void swap(T& i, T& j)
{
T temp = i;
i = j;
j = temp;
}
int main()
{
int m = 5, n = 10;
cout << "Inputs: " << m << "," << n << endl;
swap(m, n);
cout << "Outputs: " << m << "," << n << endl;
return 0;
}

但是,我遇到了编译错误。有人可以帮我找到这个问题的解决方案吗?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com