CPolynomial:Class Description CPolynomial:Copy

CPolynomial:new


The new method creates an instance of the CPolynomial class.

Note: This method's name uses all lower case to present it as the analog of the C++ new operator. Generally, the names of class methods begin with an uppercase letter but new and delete are different.

Syntax

P = CPolynomial:new()

bullet.gif    Default constructor. The new CPolynomial P has no elements.

P = CPolynomial:new( CPolynomial2 )

bullet.gif    This is a copy constructor. The new CPolynomial P is initialized to the members of the CPolynomial2 argument.

Example

The following example shows the default constructor and destructor pair:

 

P = CPolynomial:new()

-- create a new instance of P of the CPolynomial class.

  ...

-- other uses of the class go here, between new and delete.

P:delete()

-- deletes the object and its associated memory.

The next example shows the use of all 3 constructors: default, copy, and initialization:

 

P1 = CPolynomial:new()

-- default constructor

P1.Set(3, 4.4)

-- set only coef[3]

P2 = CPolynomial:new(P1)

-- copy constructor

P2:Set(2, 2.0)

-- set Coef[2]

Printf("N = %d", P2:Count())

-- result: N = 2

Related Topics

CPolynomial, Copy, delete


Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.