Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Composition, Implementation of the student class, Creating objects of one class, Relationship, Code reuse, Conceptual notation, Main Function, Output, Constructors of the sub objects are points you can learn in this Object Oriented Programming lecture.
Typology: Slides
1 / 19
*gpa : float rollNo : int name : char * Student(char * = NULL, int = 0, float = 0.0); Student(const Student &) GetName() const : const char * SetName(char ) : void ~Student() … Student
Student::Student(char * _name, int roll, float g){ cout << "Constructor::Student..\n"; if (!_name){ name = new char[strlen(_name)+1]; strcpy(name,_name); } else name = NULL; rollNumber = roll; gpa = g; }
Student::Student(const Student & st){ if(str.name != NULL){ name = new char[strlen(st.name) + 1]; strcpy(name, st.name); } else name = NULL; rollNumber = st.roll; gpa = st.g; }
**String() SetString(char ) : void GetString() const : const char * ~String() … gpa : float rollNo : int name : String Student(char * = NULL, int = 0, float = 0.0); Student(const Student &) GetName() const : String GetNamePtr() const : const char * SetName(char ) : void ~Student() … Student string : char * String
String::String(){ cout << "Constructor::String..\n"; ptr = NULL; } String::String(const String & str){ if(str.ptr != NULL){ string = new char[strlen(str.ptr)+1]; strcpy(ptr, str.ptr); } else ptr = NULL; }
void String::SetString(char * str){ if(ptr != NULL){ delete [] ptr; ptr = NULL; } if(str != NULL){ ptr = new char[strlen(str)+1]; strcpy(ptr, str); } }
class Student{ private: float gpa; int rollNumber; String name; public: Student(char* =NULL, int=0,float=0.0); Student(const Student &); void SetName(const char *); String GetName() const; const char * GetNamePtr const(); ~Student(); … };