>>120 たしかにCArrayのコピーコンストラクタで初期化できるようになったのは 改善だと思うのですが、class A に A::A(int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9) みたいなコンストラクタも欲しいなぁとなると、またconst_castの お世話になってしまいますよね・・・ CArrayの初期化の方法が、コピーコンストラクタと配列の初期化の 方法しかないからしょうがないんですけど・・・
template <class InputIterator, class Function> Function for_each (InputIterator first, InputIterator last, Function f) { while (first != last) f(*first++); return f; }
だから
(&addProcessEntry)(*first++);
ってやってる事だと解釈したんだけど… 同じ事は C だと(Cと比べるのも問題あることは分かってるけど)
ちなみに手元のUNIX機では当然にコンパイルできません。 bash-2.02# g++ -v cc -v gcc version 2.7.2.1 bash-2.02# g++ ForEachTest.cpp /usr/include/g++/algo.h: In function `void (ForEachTest::* for_each(class list<int>::iterator, class list<int>::iterator, void (ForEachTest::*)(int)))(int)': /usr/include/g++/algo.h:65: warning: argument passing to `ForEachTest *' from `int' lacks a cast /usr/include/g++/algo.h:65: too few arguments to function
test.cpp: In function `int main()': test.cpp:9: object-dependent reference `func' can only be used in a call test.cpp:9: to form a pointer to member function, say `&Foo::func' test.cpp:10: pointer to member function called, but not in class scope
>>808 その方法でやってみたんですが うまくいかなくて、、、 #include <stdio.h> class B;
class A{ private: int value; B *b; public: A(void); int get(void); int get_b(void); }; A::A(void) { value = 0; } int A::get(void) { return(value); } int A::get_b(void) { return(b->get()); }
class B{ private: int value; A *a; public: B(void); int get(void); int get_a(void); }; B::B(void) { value = 100; } int B::get(void) { return(value); } int B::get_a(void) { return(a->get()); }