Turn from: http://blog.csdn.net/feixiaoxing/article/details/6795401
The default function is a basic feature of C + +. The default function definition is simpler, that is, for one input parameter of a function or several input parameters, if you do not have a specific value, we will replace it with the default data. If you use your own data during the call, the default data will be overwritten by our own defined data. The following is an example of a default function:
View plain int Add (int m, int n = ten) {return m + N; What's the difference if it's called?
View Plain 262: int p = add (2); 00401488 push 0Ah 0040148a push 2 0040148c call @ILT +15 (add) (00401014) 00401491 add esp,8 00401494 mov dword ptr [ebp-4],eax 263: p = add (3, 4); 00401497 push 4 00401499 push 3 0040149b call @ILT +15 (add) (00401014) 004014a0 add esp,8 004014a3 mov dword ptr [ ebp-4],eax You can see from the above code, if you enter a separate data 2, then the compiler to help us enter the default 10, if the lost data is 3, 4, then the compiler will use 4 instead of the default data 10. So, the compiler helps us do the middle of the substitution and judgment work. So what happens when we go back to the default template type we're talking about today? We can write an example:
View Plain Template <typename type1, typename type2 = int> class Data {type2 value; Public