Sybase 7.5 manual Adding a Copy constructor to a class, To add a Copy constructor to a class

Models: 7.5

1 288
Download 288 pages 28.98 Kb
Page 86
Image 86

Defining operations

Adding a Copy constructor to a class

The body of a Copy constructor contains a copy of the attributes of the class that exist at the moment of the creation of the constructor.

When you create a Copy constructor, it has the same as that of the class, prefixed by the keyword new. It has a default parameter that you can modify, or you can add other parameters.

If the class is an instance of another class, the attribute names within the body of the Copy constructor operation are the same as those in the parent class.

You can define only one Copy constructor to any given class.

ϖTo add a Copy constructor to a class:

1 Double-click a class in the model.

2 Click the Operations tab.

3 Click the Add button.

4Select Copy Constructor from the dropdown list.

A Copy constructor is created at the end of the list of operations for the class. It has the same name as the class to which it belongs.

76

Page 86
Image 86
Sybase 7.5 manual Adding a Copy constructor to a class, To add a Copy constructor to a class