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

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();

    }

Posted Date: 10/18/2012 7:48:53 AM | Location : United States







Related Discussions:- Friend function in c++, Assignment Help, Ask Question on Friend function in c++, Get Answer, Expert's Help, Friend function in c++ Discussions

Write discussion on Friend function in c++
Your posts are moderated
Related Questions
Static Data Members: A data member inside the class can construct as static data member.   There are few guidelines to be followed when declaring static data member.

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. The area under a curve between two points can b

#I have assignment c with unix thread multiplication program ..

Program to find a Greatest String: C - Program: Write a program find largest string by c program. int main( int argc, char *argv[] ) {     if( argc         {


Aim: Write a program of multipication using inline function class Multiply {           int x,y;           public:           void getdata();           inline calc

Prepare data from fixed OCR areas scanned. Project Description: Project is to design software which can use character recognition only on certain areas of scanned pdf's/ jpeg

i am a engineering student and am working on a project in audio processing and so i have designed a FIR filter in Matlab . how can i get my Matlab program converted to C program?

Bubble sort C program: Write a program to define a bubble sort. void main()  {   clrscr();   int a[100],ch,n;   cout   cin>>n;   for (int i=0;i

Ask queCreate an object oriented application with C# that computes the area of a rectangle, and the area and the volume of a cuboid. Based on the inheritance concept, create a bas