class A {
public:
void fun(Array a);
void fun(Vector a);
/* Most codes in these two functions are same. */
/* Can certainly be merged into a template function if they were not member functions. */
}
請注意,我希望能有兩個類答:謝謝樂趣()這兩個版本。
當你嘗試它時發生了什麼? (提示:是的,你可以創建一個模板成員函數。) –
是嗎?什麼是問題。 –