#32_Default Construtor Arguments in C++

 #include <iostream>

using namespace std;
// Default Construtor Arguments

class complex
{
    int realcomp;

public:
    complex(int a = 0int b = 0) // '0' is default arguments
    {
        real = a;
        comp = b;
    }

    void display_complex(complex complex_number_1complex complex_number_2complex complex_number_3)
    {
        cout << "Complex 1 number is : " << complex_number_1.real << " + " << complex_number_1.comp << "i" << endl;
        cout << "Complex 3 number is : " << complex_number_2.real << " + " << complex_number_2.comp << "i" << endl;
        cout << "Complex 3 number is : " << complex_number_3.real << " + " << complex_number_3.comp << "i" << endl;
    }
};

int main()
{
    complex complex_number_1(54), complex_number_2(12), complex_number_3;
    complex_number_1.display_complex(complex_number_1complex_number_2complex_number_3);
    return 0;
}

Comments

Popular posts from this blog