Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 18th, 2012  |  syntax: None  |  size: 1.02 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. instantiation oddity
  2. int j = 0;
  3.  
  4. for (vec_i_sz i = 0; i < rifleNodes.size(); i++, j++)
  5. {
  6.     riflePickups.push_back(RiflePU(agents, mesh));
  7.     riflePickups[i].Position(nodes[rifleNodes[i]].Position());
  8.  
  9.     pickups.push_back(&riflePickups[i]);//point the pickup pointer to the rifle pickup
  10.     pickups[j]->Index(j);
  11.     pickups[j]->NodeIndex(rifleNodes[i]);
  12. }
  13.  
  14. for (vec_i_sz i = 0; i < shotgunNodes.size(); i++, j++)
  15. {
  16.     shotgunPickups.push_back(ShotgunPU(agents, mesh));
  17.     shotgunPickups[i].Position(nodes[shotgunNodes[i]].Position());
  18.  
  19.     pickups.push_back(&shotgunPickups[i]);
  20.     pickups[j]->Index(j);
  21.     pickups[j]->NodeIndex(shotgunNodes[i]);
  22. }
  23.        
  24. std::vector<Pickup*> pickups;
  25. std::vector<RiflePU> riflePickups;
  26. std::vector<ShotgunPU> shotgunPickups;
  27.        
  28. pickups(std::vector<Pickup*>()),
  29. riflePickups(std::vector<RiflePU>()),
  30. shotgunPickups(std::vector<ShotgunPU>())
  31.        
  32. Person daisy = new Person();
  33. daisy.salary = 39000;
  34. dosomethingwith(daisy);
  35.        
  36. Person* daisy = new Person();
  37. daisy->salary = 39000;
  38. dosomethingwith(daisy);