为什么编译器提示
Line3: error: expected unqualified-id before ';' token
template模版定义后面不需要引号,你去掉就可以了
max前面是不是少了<类型名>
templete是用来修饰函数的,它后面不要分号。
你也可以写在一行
templete <typename T> T max(T a, T b)
{
}
不知道为什么大家都喜欢写2行,是不是都是受谭浩强的误导。
Line3: error: expected unqualified-id before ';' token
template语句不需要分号,去掉line 3的分号。