س:لماذا عندما نحول override للدالة من صنف الاب لها حماية اكثر من public فهذا ينتج خطأ برمجي (syntax error)...أتعلم لماذا؟!
سؤال في البرمجة
الفئة التي ترث "extends" يفترض أن تضيف إلى ما ترثه، لا أن تنقص، وفي حالتك تريد أن تنقص من مجال استخدام method ما، أن تجعلها private أو protected.
اقتباسModifiers
The access specifier for an overriding method can allow more, but not less, access than the overridden method. For example, a protected instance method in the superclass can be made public, but not private, in the subclass.
You will get a compile-time error if you attempt to change an instance method in the superclass to a class method in the subclass, and vice versa.
http://download.oracle.com/javase/tutorial/java/IandI/override.html
الصراحة أني أعترض على فرضيتك يا حج عصام
لأني أرى الحذف مهم كالإضافة
ولدي أسبابي
كتبت مقالة عن الموضوع وسأضعها في أقرب وقت هنا لأسمع آراءكم حولها
تحياتي
