class Course {private: int CourseID; char* CourseName; public: Course(int=0,char[]="anonymous"); ~Course(void); int GetCourseID(); char* getCourseName(); }; Course::Course(int num,char* name) { CourseName=new char[strlen(name)+1]; strcpy(CourseName,name); CourseID=num; } |
Course(int=0,char[]="anonymous"); |
Course()
would be the same as calling Course(0,"anonymous")
Course::Course(int num,char* name) {CourseName=new char[strlen(name)+1]; strcpy(CourseName,name);} |
CourseName=new char[strlen(name)+1]; Course name=name; |
CourseName=name
you would make CourseName pointing to the same location in memory, by using
|
|