Making a copy constructor
===

I have a question about copy constructors. I see these examples on internet. 
the first one says without copy constructors if you change something on student2 the same field change also on student1. but on the second examples changes on student2 doesn't affect student1 because of copy constructor. I didn't understand how this happened, what actually copy constructors do here? (sorry for bad english)


    class MITStudent {
    public:
        int studentID;
        char *name;
        MITStudent() {
            studentID = 0;
            name = "";
    }

    };
       int main() {
          MITStudent student1;
          student1.studentID = 98;
          char n[] = "foo";
          student1.name = n;
          MITStudent student2 = student1;
          student2.name[0] = 'b';
          cout << student1.name; // boo
     }


second one






    class MITStudent {
	public:
		int studentID;
		char *name;
		MITStudent() {
			studentID = 0;
			name = "";
		}
	
		MITStudent(MITStudent &o) {
			name = my_strdup(o.name);
			studentID = o.studentID;
		}

	};
    int main() {
	   MITStudent student1;
	   student1.studentID = 98;
	   char n[] = "foo";
	   student1.name = n;
	   MITStudent student2 = student1;
	   student2.name[0] = 'b';
	   cout << student1.name; // foo
}
