Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Syntax of friend function in c++

Sehrish Zarin answered on August 23, 2021 Popularity 10/10 Helpfulness 2/10

Contents


More Related Answers

  • c++ friend class
  • c++ friend function operator overloading
  • C++ friend keyword -3 (friend class)
  • why the << operator is friend
  • 5 program code in c++ of friend function
  • c++ How to not use friend declaration when equipping a class with `operator<<`
  • friend Class in C++
  • C++ friend keyword
  • C++ friend keyword -2
  • friend Class in C++
  • friend class c++

  • Syntax of friend function in c++

    1
    Popularity 10/10 Helpfulness 2/10 Language whatever
    Link to this answer
    Share Copy Link
    Contributed on Feb 24 2023
    Sehrish Zarin
    0 Answers  Avg Quality 2/10

    Closely Related Answers



    3

    The main function creates a Rectangle object and then calls the area function with the object as its argument. Because the area function is a friend function of the Rectangle class, it has access to the private members of the object and can calculate the area of the rectangle.

    By using friend functions in C++, you can provide access to the private and protected members of a class to functions that are not members of the class, while still maintaining the encapsulation of the class's data. 

    Popularity 10/10 Helpfulness 3/10 Language cpp
    Source: Grepper
    Tags: c++
    Link to this answer
    Share Copy Link
    Contributed on Mar 07 2023
    SubZero
    0 Answers  Avg Quality 2/10

    1
    Popularity 10/10 Helpfulness 3/10 Language whatever
    Link to this answer
    Share Copy Link
    Contributed on Aug 23 2021
    Embarrassed Eagle
    0 Answers  Avg Quality 2/10

    1
    Popularity 9/10 Helpfulness 2/10 Language cpp
    Source: Grepper
    Tags: c++
    Link to this answer
    Share Copy Link
    Contributed on Jun 13 2022
    SAMER SAEID
    0 Answers  Avg Quality 2/10

    5
    Popularity 10/10 Helpfulness 2/10 Language cpp
    Tags: c++
    Link to this answer
    Share Copy Link
    Contributed on Sep 01 2021
    Fierce Fish
    0 Answers  Avg Quality 2/10

    0
    Popularity 10/10 Helpfulness 2/10 Language cpp
    Tags: c++
    Link to this answer
    Share Copy Link
    Contributed on May 19 2022
    Shahjahan Ansari
    0 Answers  Avg Quality 2/10

    0
    Popularity 9/10 Helpfulness 2/10 Language cpp
    Source: Grepper
    Tags: c++
    Link to this answer
    Share Copy Link
    Contributed on Jun 13 2022
    SAMER SAEID
    0 Answers  Avg Quality 2/10

    0
    Popularity 9/10 Helpfulness 1/10 Language cpp
    Source: Grepper
    Tags: c++
    Link to this answer
    Share Copy Link
    Contributed on Jun 13 2022
    SAMER SAEID
    0 Answers  Avg Quality 2/10

    0
    Popularity 9/10 Helpfulness 1/10 Language cpp
    Source: Grepper
    Tags: c++
    Link to this answer
    Share Copy Link
    Contributed on Jun 13 2022
    SAMER SAEID
    0 Answers  Avg Quality 2/10

    0
    Popularity 9/10 Helpfulness 1/10 Language cpp
    Source: Grepper
    Tags: c++
    Link to this answer
    Share Copy Link
    Contributed on Jun 13 2022
    SAMER SAEID
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.