行列演算用に C++ で小さな行列ライブラリを作成しています。ただし、以前はそうではなかったのに、私のコンパイラは文句を言います。このコードは 6 か月間棚に置かれ、その間にコンピューターを debian etch から lenny (g++ (Debian 4.3.2-1.1) 4.3.2) にアップグレードしましたが、同じ g++ を使用する Ubuntu システムでも同じ問題が発生します。 .
私のマトリックスクラスの関連部分は次のとおりです。
namespace Math
{
class Matrix
{
public:
[...]
friend std::ostream& operator<< (std::ostream& stream, const Matrix& matrix);
}
}
そして「実装」:
using namespace Math;
std::ostream& Matrix::operator <<(std::ostream& stream, const Matrix& matrix) {
[...]
}
これは、コンパイラによって表示されるエラーです。
matrix.cpp:459: エラー: 'std::ostream& Math::Matrix::operator<<(std::ostream&, const Math::Matrix&)' は 1 つの引数を取る必要があります
私はこのエラーに少し混乱していますが、6 か月間多くの Java を実行した後、私の C++ は少し錆びてきました。:-)