What is CPP?
Cpp programming (pronounced see plus plus) is general-purpose programming language. Cpp programming is regarded as a "middle-level" language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell Labs as an enhancement to the C programming language and originally named C with Classes. It was renamed Cpp programming in 1983.As one of the most popular programming languages ever created, C++ programming is widely used in the software industry. Some of its application domains include systems software, application software, device drivers, embedded software, high-performance server and client applications, and entertainment software such as video games.
Here you will find cpp programs and cpp class example.This is just example you can modify this cpp class example.
cpp programs
cpp class example for how do addition of two complex number using CPP
/*************************** author-Nikunj v Gandhi from-gujarat(surat) Web Developer(ZCE) email-nik_gandhi007@yahoo.com http://my-source-codes.blogspot.com/ Description: cpp class example for addition of two complex number using operator overloading ******************************************** */ #include<iostream.h> #include<conio.h> #include<math.h> class complex { float real; float imag; public: complex() { real=imag=0.0; } complex(float real1 ,float imag1=0.0) { real=real1; imag=imag1; } void input() { cout<<"Enter real part?"; cin>>real; cout<<"enter imaginary part of complex number?"; cin>>imag; } void show() { cout<<real; if(imag<0) cout<<"-i"; else cout<<"+i"; cout<<fabs(imag); } complex add(complex c2); }; complex complex::add(complex c2) { complex temp; temp.real=real+c2.real; temp.imag=imag+c2.imag; return(temp); } void main() { clrscr(); complex c1(1.5,2.0); complex c2(2.2); int i=0; cout<<"What do you want?n"; cout<<"Input data or you want to Used Initilized datan"; cout<<"If you want to input data then enter 1 otherwise 0 ? "; cin>>i; if(i==1) { cout<<"Enter value for first object?n"; c1.input(); cout<<"Enter value for second object?n"; c2.input(); } cout<<"n"; c1.show(); cout<<"n"; c2.show(); cout<<"n"; cout<<"---------------n"; complex c3; c3=c1.add(c2); c3.show(); getch(); }
No comments:
Post a Comment