1

我需要操作员声明方面的帮助。在获取输出的函数中,我是否需要将“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]);
}
4

0 回答 0