Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. List<^>^ c++ [modified]

List<^>^ c++ [modified]

Scheduled Pinned Locked Moved .NET (Core and Framework)
questionc++help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andrea Di Domenico
    wrote on last edited by
    #1

    Hello, I would to use the List type as shows below:

    this->telecommandList->Clear();
    pTelecommand^ telecommand = gcnew pTelecommand();
    pMessage ^message = gcnew pMessage();

    pField ^field = gcnew pField("Coherent Mode Select",1,"Coherency");
    message->Fields->Add(field);
    
    field->Name = "Not Used";
    field->NumBits = 15;
    field->Description = "Not Used";
    message->Fields->Add(field);
    
    telecommand->Messages->Add(message);
    telecommand->SubAddress = 10;
    
    this->telecommandList->Add(telecommand);
    

    telecommandList is declared as List<pTelecommand^> ^telecommandList; Fields is declared as List<pField^> ^Fields; and Messages is List<pMessage^> ^Messages when I write:

    field->Name = "Not Used";
    field->NumBits = 15;
    field->Description = "Not Used";

    the first field added to message->Fields List change the value, because it is a pointer to field. how can i add more different field? I have another problem with the code below:

    List ^tempCommand = gcnew List;

    for each(pMessage ^mess in this->Messages)
    {
    	mess->EncodeMessage();
    	tempCommand->Add(mess);
    }
    this->Messages = tempCommand;
    

    in this case i have the same problem described above. thank you.

    modified on Tuesday, November 2, 2010 9:55 AM

    R 1 Reply Last reply
    0
    • A Andrea Di Domenico

      Hello, I would to use the List type as shows below:

      this->telecommandList->Clear();
      pTelecommand^ telecommand = gcnew pTelecommand();
      pMessage ^message = gcnew pMessage();

      pField ^field = gcnew pField("Coherent Mode Select",1,"Coherency");
      message->Fields->Add(field);
      
      field->Name = "Not Used";
      field->NumBits = 15;
      field->Description = "Not Used";
      message->Fields->Add(field);
      
      telecommand->Messages->Add(message);
      telecommand->SubAddress = 10;
      
      this->telecommandList->Add(telecommand);
      

      telecommandList is declared as List<pTelecommand^> ^telecommandList; Fields is declared as List<pField^> ^Fields; and Messages is List<pMessage^> ^Messages when I write:

      field->Name = "Not Used";
      field->NumBits = 15;
      field->Description = "Not Used";

      the first field added to message->Fields List change the value, because it is a pointer to field. how can i add more different field? I have another problem with the code below:

      List ^tempCommand = gcnew List;

      for each(pMessage ^mess in this->Messages)
      {
      	mess->EncodeMessage();
      	tempCommand->Add(mess);
      }
      this->Messages = tempCommand;
      

      in this case i have the same problem described above. thank you.

      modified on Tuesday, November 2, 2010 9:55 AM

      R Offline
      R Offline
      Radhakrishnan G
      wrote on last edited by
      #2

      ref class Field
      {
      public:
      String^ name;
      int numBits;
      String^ description;
      };

      ref class Message
      {
      public:
      // Other members
      List<Field^>^ fields;
      };

      ref class TeleCommand
      {
      public:
      // other members
      List<Message^>^ messages;
      };

      // then your list of commands
      List<TeleCommand^>^ teleCommands;

      I think this kind of datastructure will solve your issue, also these are handles to the reference, so you can add more items using the Add method like teleCommands->messages->Add( gcnew Message()) Thanks Radhakrishnan G.

      modified on Wednesday, November 3, 2010 12:13 AM

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups