摘要:
#include <iostream> template<class T> bool compare(T &a, T &b) { return (a == b); } class Person { public: Person(std::string name, int age): name(nam 阅读全文
摘要:
#include <iostream> /* 函数模板和普通函数都实现 优先调用普通函数 */ void myswap(int &a, int &b) { std::cout << "myswap" << std::endl; int tmp = a; a = b; b = tmp; } templ 阅读全文
摘要:
#include <iostream> template<typename T> void myswap(T &a, T &b) { T tmp = a; a = b; b = tmp; } int main() { using namespace std; int a = 1; int b = 2 阅读全文