Memory Stream


Introductions

Introduce yourselves!

Icebreaker: Have you tried a VR game? If so, how was it?


Groupwork

Given sender and receiver code fragments below:

// Sender
std::stringstream ss;
char *type = “Hello world”;

ss.write(type, sizeof(type));
/* send to receiver */
// Receiver
std::stringstream ss /* = from sender */;
char *type;

ss.read(type, sizeof(type));
  1. The above won’t properly transfer the object type string "Hello world" from sender to receiver. Briefly explain why not.

  2. Add code to fix the problem (pseudo-code is fine).

  3. Instead of a char *, what if type was a Vector with (X,Y) attributes (both of type float). Would the original code (e.g., ss.write(type, sizeof(type)) work? Briefly explain why the code might not work as intended.

  4. Write code to fix the (potential) new problem.

  5. What is the “object-oriented” way to address this problem?


Hand-in

Each person in a group should submit their answers:

https://wpi.qualtrics.com/jfe/form/SV_7WGFHFoCYUIhwvI

Make sure to include the names of all group members.

Happy streaming!

– Mark