Book a Demo

Author Topic: Inner class in C++  (Read 2842 times)

billy_mumphry

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Inner class in C++
« on: November 17, 2003, 03:52:39 pm »
Hi,

I would like to generate, in C++, an inner struct (or simply a class within a class) similar to the example below.

Is this possible - or is there a workaround?

Cheers

-----------------------------------------

class A{

 private:
   struct PrivateData
   {
     int x;
     char y;
     float z;
   };

   PrivateData m_PrivateData;
};

benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: Inner class in C++
« Reply #1 on: November 19, 2003, 04:42:52 pm »
Hi billy_mumphry,

You may be able to use something like this:

1. Create class A
2. Create class PrivateData
3. Set the stereotype of PrivateData to "struct" and set its scope to "Private"
4. Create a nesting relationship from PrivateData to A
5. Create an association from A to PrivateData
6. Generate A

Warning: this approach only works for the forward generation of your class. Synchronisation of nested classes is not yet supported.

I hope this helps.

Regards,
Ben