




















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
Advanced object-oriented programming concepts, including copy constructors, destructors, accessor functions, and the this pointer. It also covers the importance of separating interface and implementation, and the use of const member functions. Examples are provided in c++ for complex number representation.
Typology: Slides
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















Student Student::setRollNo(int aNo){
… return *this; } Student Student::setName(char *aName){
… return *this; }
int
main() {
Student
aStudent;
Student
bStudent;
bStudent
=
aStudent.setName(“Ahmad”);
… bStudent
=
aStudent.setName(“Ali”).setRollNo(2);
return
0;
}
►
float getX()float getY()void setNumber
(float i, float j) float xfloat y Old implementationComplex
float getX()float getY()void setNumber
(float i, float j) float zfloat theta NewimplementationComplex
class Complex{ //new
float z;float theta; public:
void setNumber(float i, float j){
theta = arctan(j/i);…
} … };
class Student{
int rollNo; public:
void setRollNo(int aRollNo);int getRollNo();… };
#include “student.h”void Student::setRollNo(int aNo){
} int Student::getRollNo(){… }
“read-only”