ctrl++ object list

Find and share HowTos to various installations / configurations!
Search

Post Reply
2 posts • Page 1 of 1
philipp.wechsler
Posts: 13
Joined: Tue May 17, 2016 2:27 pm

ctrl++ object list

Post by philipp.wechsler »

Is there a way to create a list, array or dyn_... of ctrl++ objects? Or can I implement a generic list?

With kind regards

Philipp

philipp.wechsler
Posts: 13
Joined: Tue May 17, 2016 2:27 pm

Re: ctrl++ object list

Post by philipp.wechsler »

There is an easy way to create a list of objects with dyn_anytype. After troubleshooting I found the bug of my problem.
The order of the classes in the same script is critical!

Dosn't working MWE:

Code: Select all

class MyObject1
{
  private string sName;
  private dyn_anytype daObjects;

  public MyObject1( string sName = "" )
  {
    this.sName = sName;
  }

  public void append( MyObject2 pObject )
  {
    dynAppend( daObjects, pObject );
  }

  public MyObject2 getObject( int pNumb )
  {
    return daObjects[pNumb];
  }
};

class MyObject2
{
  private string sName;

  public MyObject( string sName = "" )
  {
    this.sName = sName;
  }
};
If I change the order of classes then can I use classes as parameter and return value in functions. Another solution exists with separate scripts for each class.

MWE:

Code: Select all

class MyObject2
{
  private string sName;

  public MyObject( string sName = "" )
  {
    this.sName = sName;
  }
};

class MyObject1
{
  private string sName;
  private dyn_anytype daObjects;

  public MyObject1( string sName = "" )
  {
    this.sName = sName;
  }

  public void append( MyObject2 pObject )
  {
    dynAppend( daObjects, pObject );
  }

  public MyObject2 getObject( int pNumb )
  {
    return daObjects[pNumb];
  }
};
Is there a possibility of forward declaration in ctrl ++?

Post Reply
2 posts • Page 1 of 1