<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Friend function &amp; class | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/friend-function-class/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Wed, 28 Dec 2022 16:30:57 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>Friend Functions &#038; Classes</title>
		<link>https://studentprojects.in/software-development/cpp/friend-functions-classes/</link>
					<comments>https://studentprojects.in/software-development/cpp/friend-functions-classes/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Wed, 18 Jan 2023 04:27:00 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Friend function & class]]></category>
		<category><![CDATA[friend classes in c++]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=10102</guid>

					<description><![CDATA[<p>Friend functions are those that, despite not being declared inside the class, have permission to access the private information of its members. The friend function prototype needs to be written. A function is not a member of a class just because it is declared as a buddy function inside the class. Properties of Friend Function</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/friend-functions-classes/">Friend Functions & Classes</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Friend functions are those that, despite not being declared inside the class, have permission to access the private information of its members. The friend function prototype needs to be written.</p>



<p>A function is not a member of a class just because it is declared as a buddy function inside the class.</p>



<h3>Properties of Friend Function</h3>



<ul>
<li>It is not a member of the class if it is not inside the scope of the class.</li>



<li>It cannot be invoked from the class&#8217;s object because it is outside of its scope.</li>



<li>It doesn&#8217;t matter where in the class it is declared, or whether it is under the public or private access modifier.</li>



<li>It needs (object name.member name) to access any member because it cannot access the members directly by name.</li>
</ul>



<p>Declaring a friend function inside a class requires the following syntax.</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">class class_name
{
    friend return_type function_name(arguments);
};
 
return_type class_name::function_name(arguments)
{
    //body of the function
}</code></pre>



<h3>Friend Classes in C++</h3>



<p>Classes that are declared as friends have access to the private members of the class in which they are used. The most important point to keep in mind is that once a class becomes friends with another class, it has access to all of its private members.</p>



<p>The syntax for a friend class declaration within a class is</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">class class_name
{
    friend class friend_class_name;
};</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/friend-functions-classes/">Friend Functions & Classes</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/friend-functions-classes/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
