Friend function in c++, C/C++ Programming

Assignment Help:

Friend function in c++:

class miles;

class km

 {

   float value;

   public :

  // void input();

    km convert(km  ,int a ) ;

   void output()

   {

   cout << value;

   }

  };

 

                                km km :: convert(km a,int b)

                                {

                                a.value = b * 1.61;

                                return a;

                                }

 

 

 

 

                class miles

                  {

                   int value;

                   public:

 

                   void input()

                   {

                   cout << "Enter the value\n";

                  cin >> value;

                   }

                   friend km & convert(km &,miles);

                   };

 

                km & convert(km & a,miles b)

                                {

                                a= b.value * 1.61;

                                return a;

                                }

 

 

   void main()

   {

     km a;

     miles b;

      clrscr();

     b.input();

 

     a= convert (a,b);

     a.output();

     getch();

    }


Related Discussions:- Friend function in c++

Explain multidimensional arrays, Multidimensional Arrays - Every dimens...

Multidimensional Arrays - Every dimension is specified in separate brackets e.g. int arr[4][3]; This is a two-dimensional array with 4 as row dimension and 3 as

Explain recursive functions, Recursive Functions Recursion is a process...

Recursive Functions Recursion is a process by which a function includes itself with a condition for its safe exit. It is best suitable for a recursive problem. A typical exampl

Area under curve, Write a program to find the area under the curve y = f(x)...

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.

Pro, i need to do my home work

i need to do my home work

What are virtual functions in c++, A virtual function permits derived class...

A virtual function permits derived classes to replace the implementation given by the base class. The compiler makes sure the replacement is always known as whenever the object in

Padovan string, A Padovan string P(n) for a natural number n is defined as:...

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2

Explain some string oriented library functions, Explain some String Oriente...

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

Sequence for DMA controller, Write a sequence of instructions that transfer...

Write a sequence of instructions that transfers data from memory to an external I/O device by using channel 3 of the 8237 DMA controller. Transfer from 20000H-20FFFH.

Integration, w.a.p to find outWrite a program to find the area under the cu...

w.a.p to find outWrite 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.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd