関数へのポインターと通常ポインターの間に違いはありますか?スタンドアローン関数にconst修飾子を使用するのが適切な場合何の警告を与えない++constへのポインターvs通常のポインター(関数用)
#include <iostream>
using namespace std;
int sum(int x, int y) { return x + y; }
typedef int sum_func(int, int);
int main()
{
const sum_func* sum_func_cptr = ∑ // const function
sum_func* sum_func_ptr = ∑ // non-const function ?
// What is the difference between sum_func_cptr and sum_func_ptr
int x = sum_func_cptr(2, 2);
cout << x << endl;
int y = sum_func_ptr(2, 2);
cout << y << endl;
sum_func_cptr = 0;
sum_func_ptr = 0;
return 0;
}
グラム:
は、私は私の質問を説明するために、短いサンプルを書きました。それが私が尋ねる理由です。
ねえ、私が話していたスタンダードの専門家がいます。 :P – GManNickG
Hehe、私は標準的なテキストでn00bです。しかし、私は分析が好きで嬉しいです:) –
私はC++ 98の標準を読んだことがあります。それが私がそれを見つけることができなかった理由です。 –