// Ex861.cc (derived from Ex851.cc <-- Ex752.cc <-- Ex643-correct.cc) // class Studenten is used // g++ Ex851.cc studenten2.cc // g++ Ex851.cc studenten3.cc (resp.) #include #include #include "studenten3.hh" int main() { Studenten robbi; // Default constructor { // start block // Constructor with args Studenten arni("Arni", "Schwarz", 812, 7938592); robbi = arni; // Assignment operator } // end block // Destructor for arni Studenten mike(robbi); // Copy constructor cout << "mike : " << mike << endl; cout << endl; // Data in Studenten are private therefore --> inaccessible: // cout << "Access to public data : "; // cout << "mike.pvorname = " << mike.pvorname << endl; // Data in Studenten are private therefore : cout << "Access to private data via methods: " << endl; cout << "mike.pvorname = " << mike.GetVorname() << endl; // mike.GetVorname()[3] = 'k'; // not allowed because of 'const' // char *pp = mike.GetVorname();// not allowed because of 'const' char tmp[40]; strcpy(tmp,mike.GetVorname()); // allowed return 0; } // Destructor for robbi, mike