ThinkTronix
learning is fun...
Home
Home
E-Books
Robotics
Coding
C++
Tutorials
Robotics
Softwares
Social Profiles
Popular
Tags
Blog Archives
Popular Posts
Volume of a Cube, Cuboid & Cylinder using Function Overloading
Write a Program to find Volume of a Cube, Cuboid & Cylinder using Function Overloading. #include<iostream> using namespace std...
Robotics: Using Atmega16 Microcontroller - Introduction
What is a Microcontroller? A microcontroller is a single chip, self-contained computer which incorporates all the basic components of...
NI Multisim 11.0
NI Multisim (formerly MultiSIM ) is an electronic schematic capture and simulation program which is part of a suite of circuit desi...
Area using Default Arguments
Write a Program to find Area of a Square & Rectangle using Default Arguments. #include<iostream> using namespace std; int sqr(...
Swap using Call by Address.
Write a Program to enter two no.s and swap their values using Call by Address. #include<iostream> using namespace std; void swap(i...
Tags
C++ code
electronics
free download
free ebooks
mediafire
programming
software
video
Blog Archive
▼
2012
(24)
►
May
(1)
►
April
(3)
▼
February
(6)
Array of Objects
Area using Default Arguments
Banking System using Class
Friend Funtion
Nesting of Member Funtions
Sum of Time Objects
►
January
(14)
►
2011
(2)
►
December
(2)
Tuesday, February 28, 2012
Friend Funtion
8:24 PM
C++ code
,
friend function
,
programming
No comments
Write a Program to find sum of two complex no.s using Friend Function.
#include<iostream> using namespace std; class complex_add { public: int x,y; void input() { cout<<"Enter the real & imaginary part of complex no.:"; cin>>x>>y; } friend void show(complex_add,complex_add,complex_add); }; void show(complex_add p,complex_add q,complex_add r) { cout<<"First complex no.:= "<<p.x<<"+i"<<p.y<<endl; cout<<"Second complex no.:= "<<q.x<<"+i"<<q.y<<endl; cout<<"Sum of complex no.:= "<<r.x<<"+i"<<r.y<<endl; } int main() { complex_add a,b,s; a.input(); b.input(); s.x=a.x+b.x; s.y=a.y+b.y; show(a,b,s); return 0; }
Email This
BlogThis!
Share to X
Share to Facebook
Newer Post
Older Post
Home
0 comments:
Post a Comment
0 comments:
Post a Comment