// student.cc #include #include "student.hh" void Copy_Student2(Student2& lhs, const Student2& rhs) { lhs = rhs; // copies int, long long int, int* // but pvorname, pname point on dynamical data are posessed by arni // ===> allocate dynamical memory for robbi // (=>redefinition of pvorname, pname) // Allocate memory for lhs.pname lhs.pname = new char[strlen(rhs.pname)+1]; strcpy(lhs.pname,rhs.pname); // and copy input on it // Allocate memory for lhs.pvorname lhs.pvorname = new char[strlen(rhs.pvorname)+1]; strcpy(lhs.pvorname,rhs.pvorname); // and copy input on it return; }