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

Assignment Help:

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();

       }

 


Related Discussions:- Create complex number using constructor

Write function that take array as argument, Write a function that takes an ...

Write a function that takes an array as the argument and returns the second largest element. Bonus (+5): Write a function that takes an array and a number n as arguments and return

PEBBLE MERCHANT, There is a pebble merchant. He sells the pebbles, that are...

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that

Constructors and destructors, Constructors and Destructors: A Class is ...

Constructors and Destructors: A Class is defined as constructor by declaring a constructor in the form of function inside the class.  In other word a function in the name of

Link list, For this program you will add and test 2 new member functions to...

For this program you will add and test 2 new member functions to the IntSLList class posted on the website. The two member functions are: insertByPosn(int el, int pos) Assuming t

Accessibility, What are the legal requirements with which websites must com...

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

C, how to learn programming skills

how to learn programming skills

Give example of the do while loop, Normal 0 false false fal...

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

C pgms, find area under the curve y=f(x) between x=a &y=b integrate y=f(x)

find area under the curve y=f(x) between x=a &y=b integrate y=f(x)

Area under curve, Write a program to find the area under the curve y = f(x)...

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. The area under a curve between two points can b

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd