Skip to content

Commit ea416ee

Browse files
authored
Merge pull request Light-City#121 from daidai21/master
FIXED issues#70 issues#106
2 parents 9920450 + 6920eff commit ea416ee

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
#include<iostream>
2-
#include<cstring>
1+
#include <cstring>
2+
#include <iostream>
33
using namespace std;
44

5-
6-
template<class T> T compareMax(T t1,T t2){
7-
return t1>t2?t1:t2;
5+
template <class T>
6+
T compareMax(T t1, T t2) {
7+
return t1 > t2 ? t1 : t2;
88
}
99

10-
template<> char* compareMax<char *>(char *s1,char *s2){
11-
return strcmp(s1,s2)>=0?s1:s2;
10+
template <>
11+
const char *compareMax<const char *>(const char *s1, const char *s2) {
12+
cout << "[for debug]" << " call compareMax template" << endl;
13+
return strcmp(s1, s2) >= 0 ? s1 : s2;
1214
}
13-
int main(int argc, char const *argv[])
14-
{
15-
cout<<compareMax(1,2)<<endl;
16-
cout<<compareMax("asda","qweq")<<endl;
17-
system("pause");
18-
return 0;
15+
int main(int argc, char const *argv[]) {
16+
cout << compareMax(1, 2) << endl;
17+
cout << compareMax("asda", "qweq") << endl;
18+
system("pause");
19+
return 0;
1920
}

0 commit comments

Comments
 (0)