الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

c++ accessor methods?

مغلق
بدأه Ghost Of Death في 27 يونيو 2003 · 1 رد · 568 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

c++ accessor methods?

what is the use of accessor methods in c++?i mean what is there importantance?

and i have another question about them,plzz see this source code:

if my class declaration was this:

5: class Cat

6: {

7: public:

8: // public accessors

9: unsigned int GetAge();

10: void SetAge(unsigned int Age);

11:

12: unsigned int GetWeight();

13: void SetWeight(unsigned int Weight);

14:

15: // public member functions

16: Meow();

17:

18: // private member data

19: private:

20: unsigned int itsAge;

21: unsigned int itsWeight;

22:

23: };

Cat Frisky;

Frisky.SetAge(5);

and i try to pass the 5 value to my accessor setage then how do the public accessor chooses the

private variable itsAge to store the 5 value,i mean why don't the public accessor setAge passes

the value 5 to the private variable itsWeight?

Regards;

Ghost Of Death

#2

Hi shbab...

يعني الموضوع موبهصعوبة ما حد شافها ولا مو فاهمين الاستفسار و لا ايش ؟؟!!

أتمنى أجد منكم الرد..

Regards;

هذا الموضوع مغلق.

مواضيع مشابهة