<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Friend Class in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/friend-class/m-p/6994644#M1494362</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Karthikeyan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;friendship can only be declared in the class which allows friendship.&lt;/P&gt;&lt;P&gt;In your example class C1 has to declare class C2 as a friend.&lt;/P&gt;&lt;P&gt;If friendship could be declared like you tried, it would be very easy to break up an encapsulation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Hubert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 May 2010 08:07:20 GMT</pubDate>
    <dc:creator>hubert_heitzer</dc:creator>
    <dc:date>2010-05-26T08:07:20Z</dc:date>
    <item>
      <title>Friend Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/friend-class/m-p/6994642#M1494360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to access private methods using friend class...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; CLASS C1 DEFINITION.&lt;/P&gt;&lt;P&gt;    PUBLIC SECTION.&lt;/P&gt;&lt;P&gt;       METHODS : M1.&lt;/P&gt;&lt;P&gt;    PRIVATE SECTION.&lt;/P&gt;&lt;P&gt;       METHODS: M2.&lt;/P&gt;&lt;P&gt;  ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    CLASS C1 IMPLEMENTATION.&lt;/P&gt;&lt;P&gt;    METHOD M1.&lt;/P&gt;&lt;P&gt;      WRITE : 'Public Method C1'.&lt;/P&gt;&lt;P&gt;    ENDMETHOD.&lt;/P&gt;&lt;P&gt;    METHOD M2.&lt;/P&gt;&lt;P&gt;      WRITE : 'Private Method C1'.&lt;/P&gt;&lt;P&gt;    ENDMETHOD.&lt;/P&gt;&lt;P&gt;  ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLASS C2 DEFINITION  CREATE PRIVATE FRIENDS C1.&lt;/P&gt;&lt;P&gt;    PUBLIC SECTION.&lt;/P&gt;&lt;P&gt;     METHODS : M3.&lt;/P&gt;&lt;P&gt;ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS C2 IMPLEMENTATION.&lt;/P&gt;&lt;P&gt;METHOD M3.&lt;/P&gt;&lt;P&gt;   data : obj TYPE REF TO C1.&lt;/P&gt;&lt;P&gt;   create OBJECT obj.&lt;/P&gt;&lt;P&gt;   CALL METHOD obj-&amp;gt;M2.                                       " Error says access to M2 is not allowed&lt;/P&gt;&lt;P&gt;WRITE 'Public Method C2'.&lt;/P&gt;&lt;P&gt;ENDMETHOD.&lt;/P&gt;&lt;P&gt;ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pllz help...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;Karthikeyan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 May 2010 07:42:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/friend-class/m-p/6994642#M1494360</guid>
      <dc:creator>karthikeyan_m4</dc:creator>
      <dc:date>2010-05-26T07:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Friend Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/friend-class/m-p/6994643#M1494361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is class C1 which has to declare friendship to class C2 in order C2 can access C1's private components, not vice versa.&lt;/P&gt;&lt;P&gt;I.e I say John is my friend (I therefore allow him to play my PS3;) ). John does not like me so much (a pitty:( ) so he doesn't allow me ride his bike.&lt;/P&gt;&lt;P&gt;So what you need is &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CLASS c2 DEFINITION DEFERRED.

CLASS c1 DEFINITION FRIENDS c2.
  PUBLIC SECTION.
    METHODS : m1.
  PRIVATE SECTION.
    METHODS: m2.
ENDCLASS.                  


CLASS c1 IMPLEMENTATION .
  METHOD m1.
    WRITE : 'Public Method C1'.
  ENDMETHOD.                    "M1
  METHOD m2.
    WRITE : 'Private Method C1'.
  ENDMETHOD.                    "M2
ENDCLASS.                    


CLASS c2 DEFINITION FRIENDS c1.  "my friends are here, allow them access to my (C2's) private components
  PUBLIC SECTION.
    METHODS : m3.
ENDCLASS.              


CLASS c2 IMPLEMENTATION.
  METHOD m3.
    DATA : obj TYPE REF TO c1.
    CREATE OBJECT obj.
    CALL METHOD obj-&amp;gt;m2.    "now I am able to call his method, as he says I am his friend
    WRITE 'Public Method C2'.
  ENDMETHOD.                    "M3
ENDCLASS.                   

START-OF-SELECTION.
  DATA obj_c2 TYPE REF TO c2.

  CREATE OBJECT obj_c2.
  obj_c2-&amp;gt;m3( ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 May 2010 08:01:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/friend-class/m-p/6994643#M1494361</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-05-26T08:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Friend Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/friend-class/m-p/6994644#M1494362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Karthikeyan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;friendship can only be declared in the class which allows friendship.&lt;/P&gt;&lt;P&gt;In your example class C1 has to declare class C2 as a friend.&lt;/P&gt;&lt;P&gt;If friendship could be declared like you tried, it would be very easy to break up an encapsulation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Hubert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 May 2010 08:07:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/friend-class/m-p/6994644#M1494362</guid>
      <dc:creator>hubert_heitzer</dc:creator>
      <dc:date>2010-05-26T08:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Friend Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/friend-class/m-p/6994645#M1494363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This was really awesome!!!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Apr 2011 06:00:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/friend-class/m-p/6994645#M1494363</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-04-12T06:00:14Z</dc:date>
    </item>
  </channel>
</rss>

