topical media & game development

talk show tell print

professional-program-12-References-ReferenceParameters.c

? / professional-program-12-References-ReferenceParameters.c


  void swap(int& first, int& second)
  {
    int temp = first;
    first = second;
    second = temp;
  }
  
  int main(int argc, char** argv)
  {
    int x = 5, y = 6;
    swap(x, y);
  
    //  swap(3, 4); // DOES NOT COMPILE
  
    int *xp = &x, *yp = &y;
    swap(*xp, *yp);
  
    return (0);
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.