C++ Programming

C++ Program to Multiply Numbers Using Function Overloading

Write a Program to multiply the three numbers using the different concepts of function overloading and default constructors.

Source Code

#include<iostream>

#include<conio.h>

using namespace std;

class mul

{

int a;

int b;

int c;

public:

mul(int i=10,int j=1,int k=2)

    {

        a=i;

        b=j;

        c=k;

    }

void showd()

    {

        cout<<"The result is :"<<a*b*c<<endl;

    }

};

int main()

{

        mul a1;

        a1.showd();

        mul a2(20);

        a2.showd();

        mul a3(20,30);

        a3.showd();

        mul a4(20,30,10);

        a4.showd();

}

 Output

Back to top button