C++ Codes
Algorithms
Algorithm Analysis in C++
Beginners
Code Snippets
Graphics
Data Structures
File Manipulation
Games
Mathematics
Miscellaneous
Visual C++ Library
C++ > Beginners Lab Assignments sample source codes
Program for Overloading the difference operator for complex arithmetic
Program for Overloading the difference operator for complex arithmetic #include
#include
class complex { float real; float img; public: complex() { real = 0; img = 0; } complex(float a,float b) { real =a ; img = b; } complex operator -(complex ); void disp(); }; // Fn.for overloading of - operator for complex arithmetic complex complex::operator-(complex a) { return complex(real-a.real,img-a.img); } // function for display of Real & Imaginary Parts void complex::disp() { cout<<" The real part is : "<
Privacy Policy
|
Link to Us
|
Links