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
BACKGROUND: FILE SYSTEMS  In a computer, a file system (sometimes written filesystem) is the way in which files are named and where they are placed logically for storage and ret

Introduction:  This assignment requires a knowledge of variables (integers, char types), loops, conditionals, switch, functions, char arrays, string arrays, number arrays, struc

Project Description: I want an app that the user can download it from the play store and use it as a keyboard for texts and writing. Just like the Samsung keyboard and the arabi

C Program for DIVISER   void main() {           int result,number,min;           clrscr();           printf("ENTER THE NUMBER=");           flushall();

What are control structures? - Control structures decide which instructions in program must be executed. - This implies that program flow may not necessarily move from one s

a palindrome is a string that reads the same from bhote the ends

write a c++ code to implement use of a constructor

i want a c or c++ code for solving transportation problem using modified distribution method

accept principal amount,rate of interest, & duration from the user. display interest amount and total amount

Raj is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''{'' and end with ''}''