Search
 
SCRIPT & CODE EXAMPLE
 

CPP

friend function in c++

class className{
  // Other Declarations
  friend returnType functionName(arg list);
};
Comment

friend Class in C++

class ClassB;

class ClassA {
   // ClassB is a friend class of ClassA
   friend class ClassB;
   ... .. ...
}

class ClassB {
   ... .. ...
}
Comment

friend function in c++

// Program to illustrate friend function

#include<iostream>

using namespace std;

class integer
{
  int a, b;
  public:
    void set_value()
    {
    a=50;
    b=30;
    }
  friend int mean(integer s);  //declaration of friend function
};

int mean(integer s)
{
  return int(s.a+s.b)/2.0; //friend function definition
}
int main()
{
  integer c;
  c.set_value();
  cout<< "Mean value:" <<mean(c);
  return 0;
}
Comment

friend Class in C++

class ClassB;

class ClassA {
   // ClassB is a friend class of ClassA
   friend class ClassB;
   ... .. ...
}

class ClassB {
   ... .. ...
}
Comment

friend Class in C++

class ClassB;

class ClassA {
   // ClassB is a friend class of ClassA
   friend class ClassB;
   ... .. ...
}

class ClassB {
   ... .. ...
}
Comment

friend Class in C++

class ClassB;

class ClassA {
   // ClassB is a friend class of ClassA
   friend class ClassB;
   ... .. ...
}

class ClassB {
   ... .. ...
}
Comment

friend Class in C++

class ClassB;

class ClassA {
   // ClassB is a friend class of ClassA
   friend class ClassB;
   ... .. ...
}

class ClassB {
   ... .. ...
}
Comment

friend Class in C++

class ClassB;

class ClassA {
   // ClassB is a friend class of ClassA
   friend class ClassB;
   ... .. ...
}

class ClassB {
   ... .. ...
}
Comment

friend Class in C++

class ClassB;

class ClassA {
   // ClassB is a friend class of ClassA
   friend class ClassB;
   ... .. ...
}

class ClassB {
   ... .. ...
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ string_t to string 
::  
:: resharper fold if statement c+ 
:: C++ program to sizes of data types 
Cpp :: basic cpp 
:: power in c++ 
Cpp :: c++ thread wait fro 1 sec 
Cpp ::  
::  
Cpp :: c++ garbage collection 
Cpp :: minheap cpp stl 
::  
Cpp ::  
::  
Cpp ::  
::  
Cpp ::  
::  
Cpp ::  
:: Maximum element in a map c++ 
Cpp :: compile and run cpp file on mac c++ 
Cpp ::  
::  
:: c++ throw index out of bound 
::  
Cpp ::  
::  
:: C++ for vs while loops 
::  
Cpp ::  
ADD CONTENT
Topic
Content
Source link
Name
2+3 =