C++相談室 part39
■ このスレッドは過去ログ倉庫に格納されています
0217デフォルトの名無しさん
05/03/14 12:06:31- T re, im;
+ double re, im;
const complex& aのようにリファレンス使えといった点は、単純化のため考えないとしてください。
>>216
main.cpp:42: error: explicit specialization in non-namespace scope `class complex'
main.cpp:42: error: invalid use of undefined type `class complex'
main.cpp:37: error: forward declaration of `class complex'
main.cpp:42: error: abstract declarator `complex&()(complex)' used as declaration
main.cpp:42: error: syntax error before `{' token
main.cpp:44: error: syntax error before `+=' token
main.cpp:47: error: syntax error before `}' token
main.cpp: In member function `complex& complex::operator+=(T) [with T = complex]':
main.cpp:54: instantiated from here
main.cpp:41: error: no match for 'operator+=' in 'this->complex::re += a'
37: class complex {
38: double re, im;
39: public:
40: complex() : re(0), im(0) { };
41: template<class T> complex& operator+=(T a) { re += a; return *this; };
42: template<> complex& operator+=<complex>(complex a) {
43: re += a.re;
44: im += a.im;
45: return *this;
46: };
47: };
■ このスレッドは過去ログ倉庫に格納されています