// derived_data_types_ex1.cpp /* Purpose: To demonstrate use of derived data types passing the instance to a function by address which is more efficient, but can be dangerous if you don't want values changed back in previous functions (like main)... */ #include using namespace std; #include "derived_data_types_ex3.h" // include header file main() { struct Student murray = { 3457, {'A','B','A','C','B'}}; replace(&murray); // notice memory address is passed up... display(murray); } // End of main() program void replace(struct Student* murph) { struct Student other = {3333, {'A','A','A','A','A'}}; *murph = other; } // End of replace() function void display(struct Student murph){ int i; cout << endl << "Here are contents of the instance (called \"murray\") of" << endl; cout << "the object (named \"Student\"):" << endl << endl; cout << "Student number: " << murph.no << endl; cout << "Grades: " ; for (i = 0; i <= 5; i++) cout << murph.grades[i] << " "; cout << endl << endl; } // End of display() function