Aggregate_Composite_Data1.htm
Aggregate data  type is a complex data structure, contains series of data, and which can be referenced as a single entity based on some kind of similarities o a relationship. The data type like string, arrays, struct, and classes are aggregated data type.

The composed aggregation, refers to life-time of the owner  of the aggregated data types and which can enforce the life of the member objects.

Aggregate and Composite Data : overview using C/C++ plugging in Eclipse

Coe used:

#include <iostream>
#include <string>
using namespace std;
class A1{
public:
A1(){ cout<<"\n constructor"; }
~A1() {cout<<"\n destructor";}
void start(){cout<<"\n \t engage"; }
void stop(){ cout<<"\n \t disengage"; }
};
class B1 {public: A1 *x;};

int main()
{
cout<<"hello";
A1 *a = new A1();
B1 *b = new B1();
a->start();a->stop();
b->x= a;// ref of a to b
// delete(a); // compostie effect
cout<<"\n aggregation effet ";
delete(b);
//b.start(); b.stop();
b->x->start();
b->x->stop();
delete(a); // finally destroy
return 0;
}
 

 
I am going to use Eclipse in a workstation (manas8x)

Now add a file

 

Add the codes, given at the beginning of this document

To show the composite effect ,under an owner's control, "life cycle of objects controlled as one unit, destroying one will destroy all ".