0

Как осуществить перегрузку, если в умножении участвует три переменные? Что-то попытался написать, но не компилируется.

int Vectors2::find_scalar_product(int vector_coordinates[], int vector_coordinates2[])
{
    Vectors2::scalar_product = (vector_coordinates[0]*vector_coordinates2[0]) + (vector_coordinates[1]*vector_coordinates2[1]) + (vector_coordinates[2]*vector_coordinates2[2]);
}
    сlass Vectors
    {
        public:
            /*...*/
        protected:
            int coordinates[3];

    };

    class Vectors2 : public Vectors
    {
        public:
            Vectors2 operator*(int coordinate[])
            {
                return Vectors2(vector_coordinates[] * coordinate[]);
            }

            Vectors2 operator*(int coordinate[]);
            int find_scalar_product(int [], int[];)

        private:
            int coordinates2[3];
            int scalar_product;
    };

2
  • 2
    а вы сами скажите что это такое: vector_coordinates[]* coordinate[] ? 6 дек 2019 в 20:48
  • 1
    @Shinkiro Судя по всему, Вы не до конца понимаете, что такое скалярное произведение, и что такое перегрузка операторов. В скалярном произведении участвуют всегда две и только две переменные. 7 дек 2019 в 7:05

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Посмотрите другие вопросы с метками или задайте свой вопрос.