class A {
int f(int x, int j) { return 2;}
decltype(f)* p;
};
給我的錯誤:Decltype的成員函數
error: decltype cannot resolve address of overloaded function
我不明白爲什麼這個錯誤甚至說話的重載函數。同樣地,我想,也許我需要使用範圍操作進入功能:
class A {
int f(int x, int j) { return 2;}
decltype(A::f)* p;
};
仍然給我的錯誤,但更清晰的描述:
error: invalid use of non-static member function 'int A::f(int, int)'
爲什麼,我不是允許使用decltype來查找成員函數的類型?或者,將成員函數設置爲static
可以消除這兩種情況下的錯誤。
你使用的是什麼編譯器和編譯器版本? –
@RichardChambers g ++ 4.8.1 – Silversonic