Programming Fundamentals (Composition Relationship)
Programming Fundamentals (Composition Relationship)
‘PointType center’, ‘void print()’ to print radius and color, ‘double calc_area()’ to
calculate area, ‘void setparam(int,int,double,char*) to set values of coordinates,
Main function and definition of class was provided and we have to implement class
member function and parameterized constructor.
Issue:
There was no issue in completion of task.
Application:
We can use a class object in another class and creating an aggregation between two
classes.
Conclusion:
Composition help us to reduce code length and gives hold on written code. We can
manipulate data in an organized way.
POST LAB:
#include<iostream>
using namespace std;
class course {
int courseNumber;
int creditHours;
public:
void setCourse(int x, int y);
void printcourse();
};
class section {
int secNumber;
course c;//composition
public:
void setSection(int, int, int);
void printsection();
};
sect[i].setSection(117, 3, sectNo);
}
system("cls");