‎2006 Oct 24 2:35 PM
Dear all,
how can I make my attributes protected or privat in an interface. The class setting up the interface has then the getter and setter methods for the attributes (even the interface has the methods too).
Kind regards
Roman
‎2006 Oct 24 2:52 PM
Why would you need to do that? I am not sure you can do that because all interface's components belong to public section of class in which they are implemented.
Message was edited by: Tomasz Kozerski
‎2006 Oct 24 2:52 PM
Why would you need to do that? I am not sure you can do that because all interface's components belong to public section of class in which they are implemented.
Message was edited by: Tomasz Kozerski
‎2006 Oct 24 3:04 PM
As far as I understand interfaces they give me a "template" for an implemantation. So everything, the methods and attributes should be public, protected or private. So if they just "template" the visible part (public) this would make sense.
Ok do I think right, the interface only holds the public components?
Kind regards
Roman
‎2006 Oct 24 3:23 PM
Yes, they are a 'public' face or template and belog to public section of a class.
‎2006 Oct 24 5:21 PM
Hi Roman,
An interface should not be pictured as a template, but more as a communication channel for different objects with common characteristics. If you want a template to create other classes, with private/protected attributes, and methods, I recommend that you use an abstract class. An abstract class will allow you to declare attributes and methods without code. Of course, you cannot instantiate an abstract class; you have to create another class that inherits from it.
Cheers,
Luc