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
Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.

Differences between a pointer and a reference 1.  A reference must always point to some object where as this restriction is not imposed on a pointer. e.g. int *pi = 0;

A: The answer to this lies actually, how they used. Along ++i(PreIncrement) the variable is incremented and new value is returned. Thus it needs one instruction to increment the va

Rules of Inheritance: Private members are not inherited; the members can be accessed only within its class. It cannot be used through the object. Protected members are


WAP TO ACCEPT MARKS OF THREE SUBJECT FOR STUDENT & CALCULATE TOTAL MARKS AND PERCENTAGE #include stdio.h> #include conio.h>   void main() {            int M1,M

The new and delete operators The C language has explained library functions- malloc() and free() for dynamic allocation and de-allocation of memory. C++ gives yet another appro

what are 3 conditions under which the sequential search of a list is preferable to binary search?

i need a detailed c program to explain the parameters of bernoulli''s equation..

1. Using Visual C++ and your OpenGL configured environment, write an application that displays a “unique” graphical scene that you designed and coded for this course. What yo