私はオブジェクト指向プログラミングに不慣れで、このクラスと私が宣言した別のクラスの引数を使用する1つのクラスの演算子を作成することが可能かどうか疑問に思っています。
私が解決しなければならない問題は、与えられた点での線形移動です。だから私はクラスを作成しましたPointそしてLinearTranslation基本的に私がしたいのは演算子を作成することです
Point operator* (Point p, LinearTranslation l)
これPoint pには、変換lを実行してから、を返しPointます。しかし、奇妙なエラーが発生しています:Point operator*(int)’ must have an argument of class or enumerated typeまたはそれLinearTranslation has not been declared。
それも可能ですか?
わかりました、それは一種の割り当てなので、私は少しだけ投稿しているので、私はクラスPoint.hを持っています
混乱してすみませんが、私は少しすべてを試していますが、うまくいきません。
#include "LinearTranslation.h"
class Point {
public:
int N;
double* coordinates;
public:
Point(int, double*);
virtual ~Point();
double operator[](int a);
//friend Point operator*(LinearTranslation l);
friend Point translation(LinearTranslation l);
};
LinearTranslation.h
#include "Point.h"
class LinearTranslation {
private:
int N;
double* vector;
double** matrix;
public:
//friend class Point;
LTrans(int,double*,double**);
LTrans(int);
virtual ~LTrans();
void write_vector();
void write_matrix();
LinearTranslation operator+(const LinearTranslation&);
friend Point& translation(LTrans l, Point p);
//friend Point& operator* (Point p, LTrans l);
};