electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
Live streaming at radio.electro-music.com

  host / artist show at your time
  Live Improvisations by Faux Pas Quartet and friends Music From Last Thursday
Please visit the chat
 Forum index » DIY Hardware and Software » ChucK programming language
nested class
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [4 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
sonoro



Joined: May 05, 2010
Posts: 2
Location: spain

PostPosted: Wed May 05, 2010 7:16 am    Post subject: nested class
Subject description: cant acces nested class
Reply with quote  Mark this post and the followings unread

If I define a nested class (for example for avoiding multiple files) I don`t know how to access it.

public class A{
class B{

}
}

A.B b; //this is not legal sintax
Back to top
View user's profile Send private message
vrachnasormora



Joined: Mar 22, 2007
Posts: 42
Location: Preveza,Greece

PostPosted: Wed May 05, 2010 10:53 am    Post subject: Reply with quote  Mark this post and the followings unread

Hi, class A needs to have at least one object of type B.Nesting B's definition inside A's doesn't also mean that A owns a B.So:
Code:
public class A
{
    class B
    {
    }
   
    B b;
}

A.b my_b;

hope that helps
Back to top
View user's profile Send private message
sonoro



Joined: May 05, 2010
Posts: 2
Location: spain

PostPosted: Wed May 05, 2010 12:48 pm    Post subject: Reply with quote  Mark this post and the followings unread

I tried with you code but chuck replies:
line(10).char(6): syntax error
Back to top
View user's profile Send private message
vrachnasormora



Joined: Mar 22, 2007
Posts: 42
Location: Preveza,Greece

PostPosted: Wed May 05, 2010 2:36 pm    Post subject: Reply with quote  Mark this post and the followings unread

Yes, you are right.Because reference assignment for object needs another syntax.I'm not sure but I think you need the @=> operator if you want both A.b and let's say my_b to refer to the same object of type B.If you, like before, just use:
Code:
public class A
{
    class B
    {
    }
   
    B b;
}
A a;
a.b;

you'll get no syntax error.I apologize for being so careless before.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [4 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
mps board

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use