Announcement

Collapse
No announcement yet.

allocation of array object

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • allocation of array object

    Hallo everyone.
    i just wanted to ask if it is possible to create following allocation.

    [highlight=cpp]
    static JobOptions joblist [100];

    for (int i = 0; i< 100i++){
    delete joblist[i];
    joblist[i] = new JobOptions(some parameter);
    }[/highlight]

    Here JopOptions is a Class an joblist is an object of that class.
    did i writte correctly?
    And it is enough to dellacated a memory so.
    thank ofr your answer.
    Zuletzt editiert von Jürgen Thomas; 22.02.2010, 12:02. Reason: [highlight] nachgetragen; bitte künftig unbedingt selbst machen und einrücken!

  • #2
    Warum sind bisherige Beiträge von dir in Deutsch und entsprechen somit der Forensprache hier?

    Warum ein erneutes Posting?

    http://entwickler-forum.de/showthread.php?t=60406
    Christian

    Comment


    • #3
      weil es am Einfachsten ist.
      Ich bin keine Deusche dewegen.
      deinem Beitrag werde ich dankbar sein.

      Comment


      • #4
        hallo.
        i also wanted to add additional information.
        for the above mentioned programm. how could i dellocated this array when i use follow.
        first it initialize a:
        for (int i = 0; i< 100; i++){
        joblist[i] = new JobOptions(some parameter);
        }

        while (true){
        for (int i = 0; i< 100; i++){
        Sleep(200);
        if ((run == true) && testnumber< number ) {
        AfxBeginThread(VTKAppThread,(LPVOID)joblist[i]);
        }
        }
        }

        Comment


        • #5
          static JobOptions joblist [100];

          Wo ist/wird der Speicher für das Array reserviert?

          Des Weiteren bleibt es dabei, dass ein Array

          a = new int[n];
          mit
          delete [] a;

          gelöscht wird. Kein delete ohne new und umgekehrt und ein einzelnes freigeben mit anschließenedem gesamten freigeben ist zielführend
          Christian

          Comment


          • #6
            JobOptions **joblist;

            joblist = new JobOptions* [100];

            Comment

            Working...
            X