double (^g)(double, double);g = ^(double m, double n) { return a + b; };// .. laterg = ^(double x, double y) { return x * y; }; // g reassigned to point to a new block; same type, so no problem// but not:// g = ^(int x) { return x + 1; }; // types are different! The literal on the right has type int(^)(int), not double(^) (double, double)!double (^h)(double, double) = g; // no problem here! h has the correct type and can be made to point to the same block as g// compare with:int i = 10, j = 11; // declaring a coupling of integersint *ptrToInt; // declaring a pointer to integersptrToInt = &i; // ptrToInt points to i// later...ptrToInt = &l // ptrToInt now points to jfloat f = 3.14;// ptrToInt = &f; // types are different! technically can be done, but compiler will warn you of the type difference. And typically you don't want to do this!int *anotherPtrToInt;anotherPtrToInt = ptrToInt; // both pointers point to the same integer's location in memory
コメント
コメントを投稿