hello every one
i just want 2 know whats the meaning of friend function
and when we have 2 add it
and if this function is in a program how can i realize that its there???? and thax
hello every one
i just want 2 know whats the meaning of friend function
and when we have 2 add it
and if this function is in a program how can i realize that its there???? and thax
تقدر تجمع من تلك الكتب خلاصة ما تريد وأن لم تفهم راسلنى أو أكتب هذا فى الموضوع وأنا بأذن الله أوضحلك ولكن أعطنى صنارة ولا تعطنى سمكة
الكتاب الأول:
http://books.google.com/books?vid=ISBN1553...s3xMBS0oITBErcM
الكتاب الثانى:
http://books.google.com/books?vid=ISBN0201...7viQsmXHRiLyrbg
الكتاب الثالث:
http://books.google.com/books?vid=ISBN1592...an1_myub55KWd9E
أرجو أن لا أكون حيرتك أكثر لكن كمل قلت سابقا أذا لم تفهم من هذه الكتب أكتب هذا فى الموضوع أو راسلنى وأنا بأذن الله سأوضحلك مفهوم كل ما تريد
سلام
befor any great jop there is a bad jop had done
u know what they say about friend
just ur friend can see ur private things..:)
if u have a class with a member function declared as a friend
that' means ,only that member function can access and display private data of that class
ex:
class time
{
private
int hr,mi,sec;
ublic:
friend void showtime(const time &t);// this is the decleration of the friend function
// the key word (friend) comes before the prototype
}
//now here we make the definition of the friend member function
void time:showTime(const time & t)
{
cout<<"hours is "<<t.hr<<"minutes are "<<t.mi<<"seconds are"<<t.sec;
}
//as u can see, we reached the private data of the class time through this member function because it's friend
hope that's help
What a Wonderful World
oh thanx guys
i think now its clear
dear say say i think what u gave 2 me was usefull but complicate
dear dantellah by ur example i understand the meaning of wat i want 2 know
thanx allllllllllooooot :)
تقدرين تخلين الـ class بكبره friend :)
#include <iostream>
using namespace std;
class My1
{
friend class My2;
private:
int a;
int b;
public:
My1()
{
a=b=5;
}
};
class My2
{
private:
My1 m;
public:
int hello()
{
m.a=6;
return m.a;
}
};
void main()
{
My2 bb;
cout<<bb.hello()<<endl;
} int hello()
{
m.a=6;
return m.a;
}هنا قدرنا بالميثود hello نعدل على الاتريبيوت حقت My1 على طول
تم تعديل هذه المشاركة بواسطة NullFlag في 27 ديسمبر 2006 في 18:37
NullFlag كتب:تقدرين تخلين الـ class بكبره friend :)#include <iostream> using namespace std; class My1 { friend class My2; private: int a; int b; public: My1() { a=b=5; } }; class My2 { private: My1 m; public: int hello() { m.a=6; return m.a; } }; void main() { My2 bb; cout<<bb.hello()<<endl; }int hello() { m.a=6; return m.a; }هنا قدرنا بالميثود hello نعدل على الاتريبيوت حقت My1 على طول
عندي تعقيب
مافهمت ايش علاقة الفريند كلاس بالميثود؟
ياريت لو تفهمني اكثر بليييييز :wacko:
friend class My2;
الكلام هذا موجود في class My1 يقول يا جماعة الخير (الاتريبيوت حقته My1 يعني) ترون (My2) ذا خوينا عادي يقدر يدخل عليكم :)
class My1
{
friend class My2;
private:
int a;
int b;
public:
My1()
{
a=b=5;
}
};لاحظي الكلاس My2 قدر يخش على الاتريبيوت حقت My1 على طول مع انها private
class My2
{
private:
My1 m;
public:
int hello()
{
m.a=6;
return m.a;
}
};يعني My1 اعطى الصلاحيات لـ My2 انه يقدر يخش عليها على طوووول بدون مشاكل بس :)
اها
اخيرا فهمت , يسلموووو خيو ^__^
هذا الموضوع مغلق.