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. Managed C++/CLI
  4. Why an error??

Why an error??

Scheduled Pinned Locked Moved Managed C++/CLI
helpquestion
2 Posts 2 Posters 2 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.
  • Y Offline
    Y Offline
    ydasari
    wrote on last edited by
    #1

    __gc struct hello{ int x; int y; }; void main() { hello* st[]= new hello* [5]; st[0]->x=199; }

    N 1 Reply Last reply
    0
    • Y ydasari

      __gc struct hello{ int x; int y; }; void main() { hello* st[]= new hello* [5]; st[0]->x=199; }

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      You have simply created an array. But you haven't created the individual array members yet! Use the following code :-

      __gc struct hello
      {
      int x;
      int y;
      };

      int _tmain(void)
      {
      hello *st[]= new hello*[5];
      for(int i=0; i<5; i++)
      st[i] = new hello();
      st[0]->x = 100;
      return 0;
      }

      Regards, Nish


      Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

      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