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
Run the following C++ program with and without preprocessor variable POSTFIX defined. #include using namespace std; extern "C" int atoi( const char *str );

I have a mini project where I need to write a code .wonder if someone can help me.I already have the forms and webmaster page done just need to code portion

A: Provided that function parameter is "const reference", compiler create temporary variable in following two ways. a) The actual argument is the correct type, however it isn't

Explain some String Oriented Library Functions? To make simpler string processing we can use special string oriented library functions. Mainly the C compilers include library f

Need help with C network program


Homework – Chapter 5 – Bowling Scores 33. Write a complete C++ program to do the following: The main program reads in and prints three bowling scores, score1, score2, and score

# Dear I want help to programmer that write C++ code for my small project as soon as posible If we can help me?..

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.

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec