Results 1 to 3 of 3

Thread: [java] access to member in composition

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Qt products
    Qt3
    Platforms
    Windows
    Thanks
    53

    Default [java] access to member in composition

    Qt Code:
    1. //a.class
    2. public class A {
    3. private static enum Day { Sun, Mon, Tue }
    4. private B b;
    5. public A (B cb) { b = cb; }
    6. friend B; //exists??
    7. }
    8. //b.class
    9. public class B {
    10. public B () { }
    11. private int DoSomething () {
    12. // here I have to acces to enum Day like switch (Day) ; but from here
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 
    Does it exists a keyword like "friend" to do this? Or Anyone can suggest me anything better!?

    Furthermore: is it possibile something like C ? (= 0 I mean)
    Qt Code:
    1. private static enum Day { Sun=0, Mon=1, Tue=2 }
    To copy to clipboard, switch view to plain text mode 
    thanks
    Last edited by mickey; 21st June 2008 at 14:51.
    Regards

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: [java] access to member in composition

    Java doesn't have the "friend" concept. In Java you have the option of nested classes or private, file scope classes.

    You can use either of them, from what I see you're trying to do.
    Last edited by marcel; 21st June 2008 at 23:26.

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: [java] access to member in composition

    Here's a nice thread that goes into the more "philosophical" aspects of this issue: http://forum.java.sun.com/thread.jsp...sageID=2358324

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.