No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Vous devez être membre et vous identifier pour publier un article.
Les visiteurs peuvent toutefois commenter chaque article par une réponse.

[C#] Inconsistent accessibility

Astuces de l’Infobrol (dotNet)Article publié le 15/10/2006 21:32:41


Si l'éditeur Visual Studio refuse de compiler en affichant une erreur de ce type :

Error 1 Inconsistent accessibility: base class 'heritage.Personne' is less accessible than class 'heritage.Lecteur' C:\Documents and Settings\steph\Local Settings\Application Data\Temporary Projects\heritage\Lecteur.cs 8 18 heritage



Il faut vérifier les niveaux d'accessibilité des classes.

Dans le cas de cet exemple, la classe Personne n'avait pas de niveau définit, mais la classe Lecteur (qui hérite de la classe Personne) avait un niveau d'accessibilité plus visible (ici public).

  1. class Personne
  2. {
  3.  
  4. private String nom;
  5. private String prenom;
  6.  
  7. ///‹summary›
  8. ///Constructeur
  9. ///‹/summary›
  10. ///‹param name="nom"›Nom de la personne‹/param›
  11. ///‹param name="prenom"›Prénom de la personne‹/param›
  12. public Personne(String nom, String prenom)
  13. {
  14. this.nom = nom;
  15. this.prenom = prenom;
  16. }
  17.  
  18. ///‹summary›
  19. ///Retourne le nom de la personne
  20. ///‹/summary›
  21. public String getNom()
  22. {
  23. return nom;
  24. }
  25.  
  26. ///‹summary›
  27. ///Retourne le prénom de la personne
  28. ///‹/summary›
  29. public String getPrenom()
  30. {
  31. return prenom;
  32. }
  33.  
  34. }
  35.  
  36. public class Lecteur : Personne
  37. {
  38.  
  39. private DateTime inscription;
  40. private ArrayList emprunts;
  41.  
  42. ///‹summary›
  43. ///Constructeur
  44. ///‹/summary›
  45. ///‹param name="nom"›Nom du lecteur‹/param›
  46. ///‹param name="prenom"›Prénom du lecteur‹/param›
  47. ///‹param name="inscription"›Date d'inscription‹/param›
  48. public Lecteur(String nom, String prenom, DateTime inscription)
  49. : base (nom, prenom)
  50. {
  51. this.inscription = inscription;
  52. }
  53.  
  54. ///‹summary›
  55. ///Retourne la liste des livres empruntés par ce lecteur en ce moment
  56. ///‹/summary›
  57. public ArrayList getEmprunts() {
  58. return emprunts;
  59. }
  60.  
  61. ///‹summary›
  62. ///Retourne la date d'inscription de ce lecteur
  63. ///‹/summary›
  64. public DateTime getInscription()
  65. {
  66. return inscription;
  67. }
  68.  
  69. ///‹summary›
  70. ///Ajoute un livre aux livres empruntés par ce lecteur en ce moment
  71. ///‹/summary›
  72. ///‹param name="livre"›Livre emprunté‹/param›
  73. public void emprunte(Livre livre)
  74. {
  75. emprunts.Add(livre);
  76. }
  77.  
  78. ///‹summary›
  79. ///Rapporte un livre à la bibliothèque
  80. ///Enlève donc le livre de ses livres empruntés en ce moment
  81. ///‹/summary›
  82. ///‹param name="livre"›Livre rapporté‹/param›
  83. public void rapporte(Livre livre)
  84. {
  85. emprunts.Remove(livre);
  86. }
  87.  
  88. }


Avatar :: Steph Un article de Steph

Source : indéterminée


Commenter l'article

Commentaires


07/02/2012 18:59:28

merci pour cette reponse ça m'a aidé )

- invité -

Sélection, tri et recherche d'articles
FILTRER :
TRIER :1er critère : 2e critère :
CHERCHER : Dans les titres Dans le contenu


[Afficher les liens en fonction des critères du formulaire ci-dessus]

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 13/09/2004, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/ast-rf-372.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.