演算子の宣言について助けが必要です。出力を取得する関数で、「test_a」の「operator+=" 関数を引数として定義する必要がありますか、それとも両方のクラスを引数として含む「operator*」関数を定義する必要がありますか。それとも、この状況では必要ありませんか?プログラムの堅牢性のためにこれを設計しようとしています。
class test_a
{
public:
//including definition of constructor/destructor/etc.
friend class test_b;
private:
float *a_value;
};
class test_b
{
public:
//including definition of constructor/destructor/etc.
test_a output(test_a&);
private:
float *b_value;
};
test_a test_b::output(test_a& x)
{
test_a final_output;
final_output.a_value[0]+=(b_value[0])*(x.a_value[0]);
}