Results 1 to 3 of 3

Thread: Question about self-referential class definition

  1. #1
    chanmarc is offline Registered User
    Name: Marco Chan
    Organization: Barcap
    Project: Risk Management system
    Join Date
    Jan 2012
    Posts
    2

    Question Question about self-referential class definition

    Hi all,

    I'm quite new to ICE and am now working on a server-side Java process which will expose an ICE interface for client app invocation. What I'm doing now is to define an .ice file and use slice2java for code generation. Everything looks pretty good until I want to define a class ABC which needs to contain a member variable with ABC array datatype (or List<ABC>).

    I tried both:

    Approach 1
    =========================
    sequence<ABC> MyList;

    class ABC {
    MyList attr1;
    };
    =========================

    and

    Approach 2
    =========================
    class ABC {
    MyList attr1;
    };

    sequence<ABC> MyList;
    =========================

    and slice2java complained both.

    May I ask the proper way to accomplish what I'm trying to do?

    Thanks a lot!

    Marco

  2. #2
    dwayne's Avatar
    dwayne is offline ZeroC Staff
    Name: Dwayne Boone
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Jan 2005
    Location
    St. John's, Newfoundland
    Posts
    397
    You should forward declare the ABC class before using it in the sequence definition.

    Code:
    // Forward declare class ABC
    class ABC;
    
    sequence<ABC> MyList;
    
    // Define class ABC
    class ABC
    {
        MyList attr1;
    };
    Dwayne Boone

  3. #3
    chanmarc is offline Registered User
    Name: Marco Chan
    Organization: Barcap
    Project: Risk Management system
    Join Date
    Jan 2012
    Posts
    2

    Cool

    Oh, it just works, brilliant!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Slice Class inheritance question
    By ractoc in forum Help Center
    Replies: 4
    Last Post: 12-20-2011, 08:37 AM
  2. Replies: 1
    Last Post: 11-29-2007, 07:26 AM
  3. bug about exception definition
    By canyoudink in forum Bug Reports
    Replies: 3
    Last Post: 07-06-2005, 09:33 AM
  4. Class definition and visibility in c++
    By aseco in forum Help Center
    Replies: 1
    Last Post: 05-09-2005, 06:22 PM
  5. About self-referential class
    By level in forum Help Center
    Replies: 8
    Last Post: 09-07-2004, 10:54 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •