topical media & game development

talk show tell print

basic-program-solutions-07-Solution7-1.c

? / basic-program-solutions-07-Solution7-1.c


  // Solution to Exercise 7_1
  include <iostream>
  using std::cout;
  using std::endl
  
  struct Sample
  {
     int value1;
     int value2;
  };
  
  int main()
  {
     Sample a;
     Sample b;
  
     a.value1 = 1;
     a.value2 = 2;
  
     cout << "a=(" << a.value1 << "," << a.value2 << ")" << endl;
  
     // b contains junk values
     cout << "b=(" << b.value1 << "," << b.value2 << ")" << endl;
  
     b = a;
     cout << "After assigning a to b:" << endl;
     cout << "b=(" << b.value1 << "," << b.value2 << ")" << endl;
  
     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.