// public_private_ex1.cpp // Purpose: This is an example of what we would have // programmed NOT using private or public // members. Refer to the other examples for // using private and public members (ex 2, 3, 4)... // NOTE: Ignore compile warnings, it will still compile... #include using namespace std; struct Student { // Define derived data type int no; char grade[14]; }; void display(Student harry); void set(Student* harry, int n, char* g); main() { Student harry; set(&harry, 975, "ABC"); display(harry); } // end of main() program void display(Student harry) { cout << harry.no << ' ' << harry.grade << endl; } // end of display() public member function void set(Student* harry, int n, char* g){ int i; (*harry).no = n; // accept the Student number received // accept Student grades received for (i = 0; g[i] != '\0' && i < 13; i++) (*harry).grade[i] = g[i]; (*harry).grade[i] = '\0'; // set the last byte to null } // end of set() function