Create complex number using constructor , C/C++ Programming

Create Complex number using constructor:

class complex

                                {

 

                                                private:

                                                int real,ima;

                                                static int count;

                                                public :

 

                                                complex (int a,int b)       //constructor

                                                {

                                                real=a;

                                                ima=b;

                                                }

                                                complex()      //default constructor

                                                {

                                                real=0;

                                                ima=0;

                                                }

                                                void show()

                                                {

                                                cout<< real<<"\n"<

                                                }

 

                                                friend complex sum(complex ,complex);

 

                                                ~complex () // destructor

                                                {

                                                }

                                };

                                int complex :: count=15;

 

                complex sum( complex a,complex b)

                {

                complex c3;

                c3.real= a.real + b.real;

                c3.ima= a.ima + b.ima;

                return c3;

                }

 

void main()

                {

                complex a,b,c;

                clrscr();

                a = complex(10,12);   //constructor

                b= complex(12,10);

                c=sum(a,b);

                c.show();

                //cout <

                getch();

       }

 

Posted Date: 10/18/2012 6:38:39 AM | Location : United States







Related Discussions:- Create complex number using constructor , Assignment Help, Ask Question on Create complex number using constructor , Get Answer, Expert's Help, Create complex number using constructor Discussions

Write discussion on Create complex number using constructor
Your posts are moderated
Related Questions
Define global variable in c++ program: How to define a global variable and need of global variable in c++ program. int main() {    int m=20;    clrscr();    for

to count number of occurances

F u nction overloading: Functions can be defined with same name.  Depending upon the type of argument passed the function will perform.  This is known function overloading


I started preparing an alternative cryptocurrency and I am way over my head. I would like help in making modifications to the open source files and then help with deployment. I wil

c program to implement least cost method


You are going to write a function that computes the total interest charged on a credit card before it is paid off. List all the inputs the function will need.

Compound Assignment Operators Apart from the binary and the unary arithmetic operators, we also have compound assignment operators. These are +=, -=, *=, /=, %=. Using these op