From 8cdadc961103b540534327e5cdf675c9c4303300 Mon Sep 17 00:00:00 2001 From: Not-envious-of-immortals <75531634+Not-envious-of-immortals@users.noreply.github.com> Date: Tue, 7 Feb 2023 03:23:17 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A8=A1=E6=9D=BF=E7=89=B9?= =?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../10_day_practice/day8/函数模板/模板特化.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/practical_exercises/10_day_practice/day8/函数模板/模板特化.cpp b/practical_exercises/10_day_practice/day8/函数模板/模板特化.cpp index 06820f7..a1c19b8 100644 --- a/practical_exercises/10_day_practice/day8/函数模板/模板特化.cpp +++ b/practical_exercises/10_day_practice/day8/函数模板/模板特化.cpp @@ -8,14 +8,19 @@ T Max(T a,T b) { } //特化 //template <> 返回类型 函数名<特化的数据类型>(参数表) {} +template<>const char * Max(const char *a,const char *b) { + return (strcmp(a,b)>=0)?a:b; +} template<>char * Max(char *a,char *b) { return (strcmp(a,b)>=0)?a:b; } int main(){ float c=5.1,d=3.2; - cout<<"2,3的最大值是:"<