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
A Constructive Example Consider an example , to model a user-defined data type for  strings. The object simulates a character array ( string ) using a character pointer and an

Refactoring Project Description: TASK 1 - DESIGN ALGORITHM You are required to design a suitable solution algorithm by using structured chart, pseudocode or flowchart. Thi

6999066263304447777077766622337778 -----> message sent by the first smuggler. my name is robert---------> message decoded by the second smuggler. Where ‘0’ denotes the "space".

how to do an array

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

how made a flow chart of prime number by using for loop

This problem familiarizes you with using random numbers in C++. The program is to compute a good approximation of π using a simulation method called "Monte Carlo". The following fi

Project Description: I want someone with experience on adding/compiling/installing the OpenVPN client software within an IP network camera's embedded operating system. Either if

C program to string compression: Write a program to define a sting and all operations on string. void main()                                 {

Operator overloading - c++ program: Write a program in c to define operator overloading. class matrix{                   private :                 int x[2][2];