G02 Answer


#include <stdio.h>
struct
{
  int watts;
  int lumens;
} bulbA, bulbB;

int main(int argc, char *argv[])
{
  /* set values for bulbA */
  bulbA.watts = 100;
  bulbA.lumens = 1710;

  /* copy values from bulbA to bulbB */
  bulbB = bulbA;
  
  /* print values of bulbA */
  printf("BulbB: watts = %d\tlumens = %d\n",   bulbB.watts, bulbB.lumens );
  system("PAUSE");	
  return 0;
} 

Comments: The identifiers bulbA and bulbB name two separate areas of memory laid out as described in the struct. The statement

  bulbB = bulbA;

copies data from one area of memory (the struct bulbA) to another area of memory (the struct bulbB).

Bug Alert! In Java, reference variables contain references to objects. An assignment statment between two reference variables merely copies the object reference in one variable into the other variable. It does not copy data from object to object.