next up previous
Next: Restriction on Activatable Up: UC++: The Language Previous: Declaring Activatable Classes

Creating Active Objects


The class Worker can now be used as a standard C++ class, and passive objects created using just static declaration or new, but the user can also create active objects of type Analyser using the function activenew_Analyser, as shown in the example code below.

int UCPP_main(int argc, char** argv)
  Analyser *a = activenew_Analyser();

  a -> insert(23);
  a -> insert(45);
  a -> insert(120);

  cout << "Average is " << a -> average() << endl;

The function activenew_Worker returns a pointer to an active object of type Worker.

There is polymorphism between the passive and active versions of Worker: other functions interacting with the objects can be unaware of whether the objects are local or remote.

send comments or suggestions to

Click here for more information on UCL-CS.