template <class ElementType,int Dimension=1>
class Vector : public vector<ElementType> {
public:
Vector & operator+= (const Vector & a){
cout << " a " << a << endl;
transform (this->begin(), this->end(), a.begin(), this->begin(), plus<ElementType>());
return *this;
};
friend ostream & operator<< (ostream & stream, Vector t) {
stream << "(";
copy (t.begin(), t.end()-1, ostream_iterator<ElementType>(stream,","));
return stream << *(t.end()-1) << ")";
};
};
1) 実行時にエラー メッセージが表示されます。
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
このメッセージの原因は次のとおりです。cout << " a " << a << endl;
2)その操作は正常に終了しませんでしたが、aの内容の代わりにcout << .....
ゴミが追加されました。this
助言がありますか?