Проблема с дружественным методом friend c++

Здравствуте, дело в том что код полностью рабочий но нужно убрать все friend-ы к сожалению у меня самого не получатеся (((

#include <iostream>
#include <math.h>
#include <ctime>        
#include <string>
#include <vector>

using namespace std;

class matrix { //Отвечает за создание матрицы
    int mat_strok, matrix_stolbci; //Строки и столбцы матрицы
public:
    matrix();
    vector <int> global_vect; //Создаем вектор
    void input(); //Вызываем инпут
    void input(int mat_strok, int matrix_stolbci, int** mass);
    void outputer(); //Вызываем инпут
    void clearer();
    
    friend matrix operator+=(matrix& left, matrix& right);
    friend matrix operator-=(matrix& left, matrix& right);
    friend matrix operator*=(matrix& left, matrix& right);
    friend matrix operator * (matrix& left, int right);
    int get_matrix_stolbci();
    int get_mat_strok();
};
void matrix::input() { // Отвечает за ввод данных матрицы и вызов вывода на экран
    cout << "Vvod matrici:" << endl;
    cout << "Kolichestvo strok = ";
    cin >> mat_strok;
    while (mat_strok < 0) {
        cout << "Kolichestvo strok = ";
        cin >> mat_strok;
    }
    cout << "Kolichestvo stolbcov = ";
    cin >> matrix_stolbci;
    while (matrix_stolbci < 0) {
        cout << "Kolichestvo stolbcov = ";
        cin >> matrix_stolbci;
    }
    cout << "Matritsa soderjit:" << endl;
    int a;
    for (int i = 0; i < mat_strok; i++) {
        for (int j = 0; j < matrix_stolbci; j++) {
            cin >> a;
            global_vect.push_back(a);//добавление элемента в конец
        }
    }
    outputer();
};
void matrix::input(int MI, int NI, int** mass) { // Ввод данных в матрицу
    mat_strok = MI;
    matrix_stolbci = NI;
    for (int i = 0; i < mat_strok; i++) {
        for (int j = 0; j < matrix_stolbci; j++) {
            global_vect.push_back(mass[i][j]);
        }
    }
    outputer();
};
void matrix::outputer() { // вывод данных матрицы
    cout << "Matritsa " << mat_strok << " na " << matrix_stolbci << endl;
    for (int i = 0; i < mat_strok; i++) {
        for (int j = 0; j < matrix_stolbci; j++) {
            cout << global_vect[(i * matrix_stolbci) + j] << " ";
        }
        cout << endl;
    }
};
matrix::matrix() {};
void matrix::clearer() { //Очистка матрицы
    global_vect.clear();
    mat_strok = 0;
    matrix_stolbci = 0;
};
int matrix::get_matrix_stolbci() { // Возвращает кол-во столбцов
    return matrix_stolbci;
};
int matrix::get_mat_strok() { // Возвращает кол-во строк
    return mat_strok;
};
matrix operator+=(matrix& left, matrix& right) { //Прибовление значений с присвоением

    if ((left.get_mat_strok() == right.get_mat_strok()) && (left.get_matrix_stolbci() == right.get_matrix_stolbci())) {
        for (int i = 0; i < left.get_mat_strok(); i++) {
            for (int j = 0; j < left.get_matrix_stolbci(); j++) {
                left.global_vect[(i * left.get_mat_strok()) + j] = left.global_vect[(i * left.get_mat_strok()) + j] + right.global_vect[(i * left.get_mat_strok()) + j];
            }
        }
        return left;
    }
    else {
        cout << "Oshibka - matritsi ne ravni" << endl;
        return left;
    }
}
matrix operator-=(matrix& left, matrix& right) { //Убовление значений с присвоением

    if ((left.get_mat_strok() == right.get_mat_strok()) && (left.get_matrix_stolbci() == right.get_matrix_stolbci())) {
        for (int i = 0; i < left.get_mat_strok(); i++) {
            for (int j = 0; j < left.get_matrix_stolbci(); j++) {
                left.global_vect[(i * left.get_mat_strok()) + j] = left.global_vect[(i * left.get_mat_strok()) + j] - right.global_vect[(i * left.get_mat_strok()) + j];
            }
        }
        return left;
    }
    else {
        cout << "Oshibka - matritsi ne ravni" << endl;
        return left;
    }
}
matrix operator*=(matrix& left, matrix& right) { //Умножение значений с присвоением

    if (left.get_matrix_stolbci() == right.get_mat_strok()) {
        cout << "1" << endl;
        int LM = left.get_mat_strok(), RN = right.get_matrix_stolbci();
        int** mass = new int* [left.get_matrix_stolbci()];
        for (int i = 0; i < left.get_matrix_stolbci(); i++) {
            mass[i] = new int[right.get_mat_strok()];
        }
        int** massL = new int* [left.get_matrix_stolbci()];
        for (int i = 0; i < left.get_matrix_stolbci(); i++) {
            massL[i] = new int[left.get_mat_strok()];
        }
        int** massR = new int* [right.get_matrix_stolbci()];
        for (int i = 0; i < left.get_matrix_stolbci(); i++) {
            massR[i] = new int[right.get_mat_strok()];
        }
        cout << "2" << endl;
        cout << left.get_matrix_stolbci() << right.get_mat_strok() << " " << endl;
        for (int i = 0; i < left.get_mat_strok(); i++) {
            for (int j = 0; j < left.get_matrix_stolbci(); j++) {
                massL[i][j] = left.global_vect[(i * left.get_matrix_stolbci()) + j];
            }
        }
        cout << "2.1" << endl;
        for (int i = 0; i < right.get_mat_strok(); i++) {
            for (int j = 0; j < right.get_matrix_stolbci(); j++) {
                massR[i][j] = right.global_vect[(i * right.get_matrix_stolbci()) + j];;
            }
        }
        cout << "3" << endl;
        for (int i = 0; i < RN; i++) {
            for (int j = 0; j < LM; j++) {
                mass[i][j] = 0;
                for (int k = 0; k < LM; k++) {
                    mass[i][j] += massL[i][k] * massR[k][j];
                    cout << i << " " << j << " " << massL[i][k] << " " << massR[k][j] << " " << mass[i][j] << endl;
                }
            }
        }
        cout << "4" << endl;
        left.clearer();
        cout << "5" << endl;
        left.input(RN, LM, mass);
        cout << "6" << endl;
        return left;
    }
    else {
        cout << left.get_matrix_stolbci() << " nerovnocenno " << right.get_mat_strok() << ", nevozmojno" << endl;
        return left;
    }
}
matrix operator *(matrix& left, int right) { //Умножение
    for (int i = 0; i < (left.get_matrix_stolbci() * left.get_mat_strok()); i++) {
        left.global_vect[i] = left.global_vect[i] * right;
    }
    return left;
}
void main_case_m_matr() { //Меню матрицы
    cout << "1. Povtorniy vvod matritsi:" << endl;
    cout << "2. Slojenie matritsi:" << endl;
    cout << "3. Vichitanie matritsi:" << endl;
    cout << "4. Umnojenie matritsi:" << endl;
    cout << "5. Umnojit matritsu na chislo" << endl;
    cout << "6. Vixod" << endl;
}
int zhashita_vvoda() {
    int a;
    do {
        cout << "Vvedite znacheniye: ";
        cin >> a;
        if ((a < 1) || (a > 6)) {
            cout << endl << "Vvedite chislo ne menshe 1go i ne bolshe 6!" << endl;
        }
    } while ((a > 6) && (a < 0));
    cin.clear();
    fflush(stdin);
    return a;
}
void matritsa_vizivator() { // Пункты меню матрицы
    int action = -1, num = 0;
    cout << "Vvod dannix" << endl;
    matrix menu_mtrx;
    menu_mtrx.input();
    matrix mtrx_sec_inp;
    while (action != 6) {
        main_case_m_matr();
        action = zhashita_vvoda();
        switch (action) {
        case 1:
            menu_mtrx.clearer();
            menu_mtrx.input();
            break;
        case 2:
            mtrx_sec_inp.clearer();
            mtrx_sec_inp.input();
            menu_mtrx += mtrx_sec_inp;
            menu_mtrx.outputer();
            break;
        case 3:
            mtrx_sec_inp.clearer();
            mtrx_sec_inp.input();
            menu_mtrx -= mtrx_sec_inp;
            menu_mtrx.outputer();
            break;
        case 4:
            mtrx_sec_inp.clearer();
            mtrx_sec_inp.input();
            menu_mtrx *= mtrx_sec_inp;
            menu_mtrx.outputer();
            break;
        case 5:
            cout << "Vvedite chislo dlya umnojeniya:" << endl;
            cin >> num;
            menu_mtrx = menu_mtrx * num;
            menu_mtrx.outputer();
            break;
        case 6:
            menu_mtrx.clearer();
            mtrx_sec_inp.clearer();
            break;
        }
    }
}


class polinom { // Объявление вектора полинома и операции над ним
public:
    int M;
    vector <int> glob_vec;
    void input();
    void input(int M, int* mass);
    void outputer();
    void clearer();
    friend polinom operator+=(polinom& left, polinom& right);
    friend polinom operator-=(polinom& left, polinom& right);
    friend polinom operator*=(polinom& left, polinom& right);
    friend polinom operator * (polinom& left, int right);
    int get_mat_strok();
};
void polinom::input() { // Ввод данных
    cout << "Vvedite polinom:" << endl;
    cout << "M = ";
    cin >> M;
    cout << "Polinom soderjit:" << endl;
    int a;
    for (int i = -1; i < M - 1; i++) {
        cin >> a;
        glob_vec.push_back(a);
    }
    outputer();
};
void polinom::input(int MI, int* mass) {
    M = MI;
    for (int i = 0; i < M; i++) {
        glob_vec.push_back(mass[i]);
    }
    outputer();
};
void polinom::outputer() { // Вывод данных
    cout << glob_vec[0] << " + ";
    cout << glob_vec[1] << "x";
    for (int i = 2; i < M; i++)
        cout << " + " << glob_vec[i] << "x^" << i;
    cout << endl;

};
void polinom::clearer() {
    glob_vec.clear();
    M = 0;
};
int polinom::get_mat_strok() {
    return M;
};
polinom operator+=(polinom& left, polinom& right) { //A+=B
    cout << "Slojenie" << endl;
    if ((left.get_mat_strok() == right.get_mat_strok())) {
        for (int i = 0; i < left.get_mat_strok(); i++) {
            left.glob_vec[i] = left.glob_vec[i] + right.glob_vec[i];
        }
        return left;
    }
    else {
        cout << "Oshibka polinomi ne ravni" << endl;
        return left;
    }
};
polinom operator-=(polinom& left, polinom& right) { //A-=B
    cout << "Vichitanie" << endl;
    if ((left.get_mat_strok() == right.get_mat_strok())) {
        for (int i = 0; i < left.get_mat_strok(); i++) {
            left.glob_vec[i] = left.glob_vec[i] - right.glob_vec[i];
        }
        return left;
    }
    else {
        cout << "Oshibka matritsi ne ravni" << endl;
        return left;
    }
}
polinom operator *=(polinom& left, polinom& right) { //A*=B
    cout << "Umnojenie" << endl;
    for (int i = 0; i < (1 * left.get_mat_strok()); i++) {
        left.glob_vec[i] = left.glob_vec[i] * right.glob_vec[i];
    }
    return left;
}
polinom operator *(polinom& left, int right) { //A*=B
    for (int i = 0; i < (1 * left.get_mat_strok()); i++) {
        left.glob_vec[i] = left.glob_vec[i] * right;
    }
    return left;
}
void main_case_m_poln() {
    cout << "1. Vvesti osnovnoy polinom povtorno:" << endl;
    cout << "2. Slojenie polinomov:" << endl;
    cout << "3. Vichitanie polinomov:" << endl;
    cout << "4. Umnojenie polinomov:" << endl;
    cout << "5. Umnojit polinom na chislo:" << endl;
    cout << "6. Vixod" << endl;
}

void polinom_vizivator() {
    int action = -1, num = 0;
    cout << "Vvod " << endl;
    polinom menu_polinm;
    menu_polinm.input();
    polinom menu_poli_two;
    while (action != 6) {
        main_case_m_poln();
        action = zhashita_vvoda();
        switch (action) {
        case 1:
            menu_polinm.clearer();
            menu_polinm.input();
            break;
        case 2:
            menu_poli_two.clearer();
            menu_poli_two.input();
            menu_polinm += menu_poli_two;
            menu_polinm.outputer();
            break;
        case 3:
            menu_poli_two.clearer();
            menu_poli_two.input();
            menu_polinm -= menu_poli_two;
            menu_polinm.outputer();
            break;
        case 4:
            menu_poli_two.clearer();
            menu_poli_two.input();
            menu_polinm *= menu_poli_two;
            menu_polinm.outputer();
            break;
        case 5:
            cout << "Vvedite znacheniye dlya umnojeniya:" << endl;
            cin >> num;
            menu_polinm = menu_polinm * num;
            menu_polinm.outputer();
            break;
        case 6:
            menu_polinm.clearer();
            menu_poli_two.clearer();
            break;
        }
    }
}

class basic_smpl_class
{
protected:
    double x, y, g, j;
public:
    basic_smpl_class() {}
    basic_smpl_class(double a, double b)
    {
        x = a;
        y = b;
    }
    virtual double dlina_vect()//функция вызывающая дочерние методы
    {
        return pow(x * x + y * y, 0.5);
    }
    virtual double desdrob()
    {
        return x / y;
    }
    void vector_vvoder() {
        cout << "Vvedite Х: x=";
        if (!(cin >> x)) {
            cout << "Oshibka\n";
            cin.clear();
            fflush(stdin);              //очищаем поток ввода
            vector_vvoder();
        }
        else {
            cout << endl << "Vvedite Y: y=";
            if (!(cin >> y)) {
                cout << "Oshibka\n";
                cin.clear();
                fflush(stdin);
                vector_vvoder();
            }
            else { basic_smpl_class A(x, y); }
        }
    }
    void vector_pluser()
    {
        double chisl = 0;
        cout << endl << "Pribovlyaem k vectoru :";
        cin >> chisl;
        x = x + chisl;
        y = y + chisl;
    }
    void drob_pluser()
    {
        int chisl = 0;
        cout << "Pribovlyaem k drobi :";
        cin >> chisl;
        x = x + chisl * y;
    }
    void kompl_pluser()
    {
        int chisl = 0;
        cout << "Pribovlyaem k kompleksnomu chislu :";
        cin >> chisl;
        x = x + chisl;
    }
    void vector_minuser()
    {
        double chislX = 0;
        cout << endl << "Otnimaem s vectora :";
        cin >> chislX;
        x = x - chislX;
        y = y - chislX;
    }
    void drob_minuser()
    {
        double chislX = 0;
        cout << "Otnimaem s drobi :";
        cin >> chislX;
        x = x - chislX * y;
    }
    void kompl_minuser()
    {
        double chislX = 0;
        cout << "Otnimaem s kompleksnogo chisla :";
        cin >> chislX;
        x = x - chislX;
    }
    void vector_umno_obj()
    {
        double g, j;
        cout << endl << "Vvedite koordinatu X2: x="; cin >> g; cout << '\n';
        cout << "Vvedite koordinatu Y2: y="; cin >> j; cout << '\n';
        cout << "Rezultat: " << dlina_vect() * (pow(g * g + j * j, 0.5)) << endl;
    }
    void drob_umno_obj()
    {
        cout << "Chislitel X2: x="; cin >> g; cout << '\n';
        cout << "Znaminatel Y2: y="; cin >> j; cout << '\n';
        cout << "Drob 2=" << endl
            << ' ' << g << endl
            << "--------------" << endl
            << ' ' << j << endl;
        cout << "Rezultat: " << (x / y) * (g / j) << endl;
        basic_smpl_class A(g, j);
    }
    void kompl_umnoj_obj()
    {
        cout << "Veshestvenaya chast X2: x="; cin >> g; cout << '\n';
        cout << "Mnimaya chast Y2: y="; cin >> j; cout << '\n';
        cout << x << '+' << y << 'i' << " * " << g << '+' << j << 'i' << '=' << x * g - y * j
            << '+' << x * j + y * g << 'i' << endl;
        basic_smpl_class A(g, j);
    }
    void vector_umnojator()
    {
        double chislY = 0;
        cout << "Vvedite znacheniye dlya umnojeniya ";
        cin >> chislY;
        x = x * chislY;
        y = y * chislY;
    }
    virtual void vector_vivoder()
    {
        cout << "\nKoordinati vectora x= " << x;
        cout << "\nKoordinati vectora y= " << y;
        cout << '\n' << "Dlina vectora: L=" << dlina_vect();

    }
    void drob_umnojator()
    {
        double chislY = 0;
        cout << "Vvedite znacheniye dlya umnojeniya ";
        cin >> chislY;
        x = x * chislY;
    }
    virtual void drob_vivoder()
    {
        cout << ' ' << x << endl
            << "--------------" << endl
            << ' ' << y << endl;
        cout << "V vide stroki =" << x / y << endl;
    }
    void kompl_umnojator()
    {
        double chislY = 0;
        cout << "Vvedite znacheniye dlya umnojeniya :";
        cin >> chislY;
        x = x * chislY;
        y = y * chislY;
    }
    virtual void kompl_vivoder()
    {
        cout << "\nKompleksnoe chislo= " << x << '+' << y << 'i' << endl;
    }
    void clearer() {
        dlina_vect();
        desdrob();
        x = 0;
        y = 0;
        g = 0;
        j = 0;
    }
};


void main_case_m() {

    cout << "1 - Rabota s matrisey" << endl;
    cout << "2 - Rabota s polinomom" << endl;
    cout << "3 - Rabota s vektorom" << endl;
    cout << "4 - Rabota s drobyu" << endl;
    cout << "5 - Rabota s kompleksnim chislom" << endl;
    cout << "6 - Vixod" << endl;
}
void All_caller() {
    int action = -1, num = 0;
    basic_smpl_class* pMenu_arr;
    basic_smpl_class Menu_arr;
    cout << "Viberite punkt: " << endl;
    while (action != 6) {
        main_case_m();
        action = zhashita_vvoda();
        switch (action) {
        case 1:
            matritsa_vizivator();
            break;
        case 2:
            polinom_vizivator();
            break;
        case 3:
            cout << "Vektori:" << endl;
            Menu_arr.vector_vvoder();
            Menu_arr.vector_vivoder();
            cout << endl << "Slojenie:";
            Menu_arr.vector_pluser();
            Menu_arr.vector_vivoder();
            cout << endl << "Vichitanie:";
            Menu_arr.vector_minuser();
            Menu_arr.vector_vivoder();
            cout << endl << "Umnojenie:";
            Menu_arr.vector_umnojator();
            Menu_arr.vector_vivoder();
            cout << endl << "Umnojenie na obekt:";
            Menu_arr.vector_umno_obj();
            Menu_arr.clearer();
            break;
        case 4:
            cout << "Drobi:" << endl;
            Menu_arr.vector_vvoder();
            Menu_arr.drob_vivoder();
            cout << endl << "Slojenie:";
            Menu_arr.drob_pluser();
            Menu_arr.drob_vivoder();
            cout << endl << "Vichitanie:";
            Menu_arr.drob_minuser();
            Menu_arr.drob_vivoder();
            cout << endl << "Umnojenie:";
            Menu_arr.drob_umnojator();
            Menu_arr.drob_vivoder();
            cout << endl << "Umnojenie na obekt:";
            Menu_arr.drob_umno_obj();
            Menu_arr.drob_vivoder();
            Menu_arr.clearer();
            break;
        case 5:
            cout << "Kompleksnoe chislo:" << endl;
            Menu_arr.vector_vvoder();
            Menu_arr.kompl_vivoder();
            cout << endl << "Slojenie:";
            Menu_arr.kompl_pluser();
            Menu_arr.kompl_vivoder();
            cout << endl << "Vichitanie:";
            Menu_arr.kompl_minuser();
            Menu_arr.kompl_vivoder();
            cout << endl << "Umnojenie:";
            Menu_arr.kompl_umnojator();
            Menu_arr.kompl_vivoder();
            cout << endl << "Umnojit na obekt:" << endl;
            Menu_arr.kompl_umnoj_obj();
            Menu_arr.clearer();
            break;
        case 6:
            Menu_arr.clearer();
            break;
        }
    }
}
int main() {
    All_caller();
    system("pause");
    return 0;
}

Ответы (0 шт):