



























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




























Name
RollNn
Heap
A H M A D
GPA
Name
RollNn
int main(){ Student studentA(“Ahmad”,1); { Student studentB = studentA;
Name
RollNn
Heap
A H M A D
GPA
Name
RollNn
Student::Student( const Student & obj){ int len = strlen(obj.name); name = new char[len+1] strcpy(name, obj.name); … /copy rest of the data members/**
}
int main(){ Student studentA(“Ahmad”,1); { Student studentB = studentA; A H M A D
Name
RollNn
Name
RollNn
A H M A D
class Student
{
…
public:
~Student(){ if(name){ delete []name; } }
}
Student::Student(char * aName){
… cout << aName << “Cons\n”; } Student::~Student(){ cout << name << “Dest\n”; }
};